what's //S and //D

i understand //S is used to form a regular expression containing Non-white space. Then, what could be a non white spaceSame with //D - what's non digit character
[176 byte] By [ramkria] at [2007-11-27 6:41:07]
# 1
You now what inversion is?
quittea at 2007-7-12 18:10:35 > top of Java-index,Java Essentials,Java Programming...
# 2
Question for question is not the answer. please give me the answer if you know it. Otherwise, keep quite.
ramkria at 2007-7-12 18:10:35 > top of Java-index,Java Essentials,Java Programming...
# 3
That does it.
quittea at 2007-7-12 18:10:35 > top of Java-index,Java Essentials,Java Programming...
# 4
> Question for question is not the answer. please give> me the answer if you know it. Otherwise, keep quite.hehe
fastmikea at 2007-7-12 18:10:35 > top of Java-index,Java Essentials,Java Programming...
# 5
//D a single non digit Equivalent to [^0-9]
fastmikea at 2007-7-12 18:10:35 > top of Java-index,Java Essentials,Java Programming...
# 6

class RegexDemo{

public static void main(String[] args){

String str = "abcd efghi klmn";

String[] strArr = str.split("\\S");

for(String str1: strArr)

System.out.println("1"+str1);

}

}

it prints 10 times "1". can you please explain how this is working. i think it shoud print "1" 13 times.

thanks

ramkria at 2007-7-12 18:10:35 > top of Java-index,Java Essentials,Java Programming...
# 7
> it prints 10 times "1". can you please explain how> this is working. i think it shoud print "1" 13> times.I think it should print '1' 10 times but then I have read the Javadoc and I don't bite the hand that feeds me as you did in reply #2 .
sabre150a at 2007-7-12 18:10:35 > top of Java-index,Java Essentials,Java Programming...
# 8
> Question for question is not the answer. please give> me the answer if you know it. Otherwise, keep quite.1) Screw you, idiot.2) //S and //D are just literals consiting of two slashes and a letter. Pay closer attention.
jverda at 2007-7-12 18:10:35 > top of Java-index,Java Essentials,Java Programming...
# 9
> //D a single non digit Equivalent to [^0-9]No, it's a / and another / and a capital D.
jverda at 2007-7-12 18:10:35 > top of Java-index,Java Essentials,Java Programming...
# 10
does anybody know the the answer for this or not? please help.
ramkria at 2007-7-12 18:10:35 > top of Java-index,Java Essentials,Java Programming...
# 11
> does anybody know the the answer for this or not? Yes! I do!> please help.Read the Javadoc.
sabre150a at 2007-7-12 18:10:35 > top of Java-index,Java Essentials,Java Programming...
# 12
can you please pass me the link
ramkria at 2007-7-12 18:10:35 > top of Java-index,Java Essentials,Java Programming...
# 13
> can you please pass me the linkwww.google.co.uk
sabre150a at 2007-7-12 18:10:35 > top of Java-index,Java Essentials,Java Programming...
# 14
> can you please pass me the linkhere http://tehintarnet.com
ScarletPimpernela at 2007-7-12 18:10:35 > top of Java-index,Java Essentials,Java Programming...
# 15

please read the String.split(String) and String.split(String,int) documentation

http://java.sun.com/javase/6/docs/api/java/lang/String.html#split(java.lang.String)

and it's more helpfull to do thisSystem.out.println("'" + str1 + "'");

Message was edited by:

S_i_m_u

S_i_m_ua at 2007-7-21 22:02:14 > top of Java-index,Java Essentials,Java Programming...
# 16

> please read the String.split(String) and

> String.split(String,int) documentation

> http://java.sun.com/javase/6/docs/api/java/lang/String

> .html#split(java.lang.String)

>

> and it's more helpfull to do

> thisSystem.out.println("'" + str1 +

> "'");

>

Spoilsport!

sabre150a at 2007-7-21 22:02:14 > top of Java-index,Java Essentials,Java Programming...
# 17
i've already read the documentation of Pattern and split() method. I could not understand what is a non-whitespace character. If someone could explain how the compiler is spliting with delimeter \\S in my example, that would clear my doubt. Thanks
ramkria at 2007-7-21 22:02:14 > top of Java-index,Java Essentials,Java Programming...
# 18
Until you apologize to 'quitte' for reply #2 I won't help and I hope others won't either.
sabre150a at 2007-7-21 22:02:14 > top of Java-index,Java Essentials,Java Programming...
# 19
i didn't saying anything wrong. No chance for apology.
ramkria at 2007-7-21 22:02:14 > top of Java-index,Java Essentials,Java Programming...
# 20
> i didn't saying anything wrong. No chance for apology.No Soup for you!
ScarletPimpernela at 2007-7-21 22:02:14 > top of Java-index,Java Essentials,Java Programming...
# 21
> i didn't saying anything wrong. No chance for apology.:-) No chance for an explanation from me then.
sabre150a at 2007-7-21 22:02:14 > top of Java-index,Java Essentials,Java Programming...
# 22

> i didn't saying anything wrong.

yes you did

> i've already read the documentation of Pattern and split() method.

read it again, this time with your brain ON.

> I could not understand what is a non-whitespace character.

do you perhaps understand what a non-intelligent person is?

> If someone could explain how the compiler is spliting with delimeter > \\S in my example, that would clear my doubt.

the compiler doesn't splite anything. if you wrote a couple more examples and thought about the output, your doubt would be cleared. at that point, you might even understand why the first reply did give you an answer

OnBringera at 2007-7-21 22:02:14 > top of Java-index,Java Essentials,Java Programming...
# 23
why all of you are united to defend sabre150. what biscuits is he giving you. Ha ha ha.............
ramkria at 2007-7-21 22:02:14 > top of Java-index,Java Essentials,Java Programming...
# 24
he's teh boss here
Dalzhima at 2007-7-21 22:02:14 > top of Java-index,Java Essentials,Java Programming...
# 25
> Question for question is not the answer. please give> me the answer if you know it. Otherwise, keep quite.All those that know the answer are going to keep quiet.Good luck to you.
Aknibbsa at 2007-7-21 22:02:14 > top of Java-index,Java Essentials,Java Programming...
# 26
> why all of you are united to defend sabre150. what> biscuits is he giving you. Ha ha ha.............Garibaldi!
ScarletPimpernela at 2007-7-21 22:02:14 > top of Java-index,Java Essentials,Java Programming...
# 27
> > why all of you are united to defend sabre150. what> > biscuits is he giving you. Ha ha ha.............> > Garibaldi!:yum: Dead flies.
mlka at 2007-7-21 22:02:14 > top of Java-index,Java Essentials,Java Programming...
# 28
if he's the boss, then i sincerely ask for apology. I'm extremely sorry quitte
ramkria at 2007-7-21 22:02:14 > top of Java-index,Java Essentials,Java Programming...
# 29
\d A digit: [0-9]\D A non-digit: [^0-9]\s A whitespace character: [ \t\n\x0B\f\r]\S A non-whitespace character: [^\s]From: http://java.sun.com/j2se/1.4.2/docs/api/java/util/regex/Pattern.html
prometheuzza at 2007-7-21 22:02:14 > top of Java-index,Java Essentials,Java Programming...
# 30
> i didn't saying anything wrong.Wrong.> No chance for apology.No chance for help. At least from me. One more for the killfile.
jverda at 2007-7-21 22:02:19 > top of Java-index,Java Essentials,Java Programming...
# 31

> if he's the boss, then i sincerely ask for apology.

> I'm extremely sorry quitte

I'm not the boss - there is no boss. Your response to quitte's response was well out of order. quitte was asking a very valid question which for some reason you felt the need to attack.

Since I am now known to not be the boss do you still apologize to quitte?

sabre150a at 2007-7-21 22:02:19 > top of Java-index,Java Essentials,Java Programming...
# 32

I got this stuff from the API document boss. I understand that \\s represents whitespace. space, tab, line, and form-feed. but i dont understand how it behaves in case of \\S

class RegexDemo{

public static void main(String[] args) {

String str = "abcdefghijklm";

String[] strArr = str.split("\\S");

for(String str1:strArr)

System.out.println("1"+str1);}

}

in this case, it doesn't print anything. but if i change

str = "abcd efghi jklm"

then , it prints "1" 10 times.

please explain.

ramkria at 2007-7-21 22:02:19 > top of Java-index,Java Essentials,Java Programming...
# 33

> I got this stuff from the API document boss. I

> understand that \\s represents whitespace. space,

> tab, line, and form-feed. but i dont understand how

> it behaves in case of \\S

>

> class RegexDemo{

> public static void main(String[] args) {

>String str = "abcdefghijklm";

> String[] strArr = str.split("\\S");

> for(String str1:strArr)

>System.out.println("1"+str1);}

> ode]

>

> in this case, it doesn't print anything. but if i

> change

> [code]str = "abcd efghi jklm"

> then , it prints "1" 10 times.

>

> please explain.

Not until you apologize to 'quitte' knowing that I am not in charge.

sabre150a at 2007-7-21 22:02:19 > top of Java-index,Java Essentials,Java Programming...
# 34
ok. i apologize quitte if i hurt you in any manner. sorry......
ramkria at 2007-7-21 22:02:19 > top of Java-index,Java Essentials,Java Programming...
# 35

> ok. i apologize quitte if i hurt you in any manner.

> sorry......

The javadoc for split(String regex) is

http://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html#split(java.lang.String)

which is equivalent to

http://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html#split(java.lang.String,%20int)

with a second parameter of zero which means that trailing fields with zero width are discarded.

Edit: of course no thanks are necessary.

Message was edited by:

sabre150

sabre150a at 2007-7-21 22:02:19 > top of Java-index,Java Essentials,Java Programming...