0

Hello!

I write a simple java program. The user will give a URL adres which have some flags. I will parse the URL by this flags.

For example the user will give www.exampledomain.com/abc/[[FLAG1]]/abc_[[FLAG2]]gfc
I need to parse load to string parsing the URL:
String[1]=www.exampledomain.com/abc/
String[2]=/abc_
String[3]=gfc

I need to ask two questions here:

First
new Scanner("www.exampledomain.com/abc/[[FLAG1]]/abc_[[FLAG2]]gfc").useDelimiter("[[|]]");
my_scanner.next(); ==> why returns me null?

Second, which character i must use for flags? Which characters are not allowing on URL? [ or \ or something else? (I use on example [[ ]] because i did not know a character will not catch by delimiter)

Thank you!

2
Contributors
2
Replies
3
Views
5 Years
Discussion Span
Last Post by selma_aktra
0

It executes for me:

Scanner my_scanner = new Scanner("www.exampledomain.com/abc/[[FLAG1]]/abc_[[FLAG2]]gfc").useDelimiter("[[|]]");
      System.out.println(my_scanner.next()); //==> www.exampledomain.com/abc/[[FLAG1]]/abc_[[FLAG2]]gfc
0

It executes for me:

Scanner my_scanner = new Scanner("www.exampledomain.com/abc/[[FLAG1]]/abc_[[FLAG2]]gfc").useDelimiter("[[|]]");
      System.out.println(my_scanner.next()); //==> www.exampledomain.com/abc/[[FLAG1]]/abc_[[FLAG2]]gfc

Yes you tell true. I saw it now it returns all the string. But i did not want that.

my_scanner.next() must not return all the string as you show me:

System.out.println(my_scanner.next()); //==> www.exampledomain.com/abc/[[FLAG1]]/abc_[[FLAG2]]gfc

In first use my_scanner.next() must return the www.exampledomain.com/abc/, on the second use /abc_, and on the third use gfc.


--------

I test it now. useDelimiter can parse the string if i send to useDelimiter method any character. That means useDelimiter does not allow [ or ] character. I don't know what to do...

Edited by selma_aktra: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.