Regular Expression

42.0000 702.0000 moveto (6 fuel - 4.0%u235,3.35%gd2o3) show

42.0000 678.0000 moveto (8 outer clad - zr2.5nb) show

My expression is.

s.match("\s+\d+\w+\D+\W+\S+");

right or wrong?

and how can I get the last substring which is "show"?

Thanks

[308 byte] By [ardmorea] at [2007-11-27 9:19:03]
# 1

> 42.0000 702.0000 moveto (6 fuel - 4.0%u235,3.35%gd2o3) show

> 42.0000 678.0000 moveto (8 outer clad - zr2.5nb) show

>

> My expression is.

> s.match("\s+\d+\w+\D+\W+\S+");

>

> right or wrong?

Wrong: it doesn't compile.

What is it you're trying to match? The entire line? You'll have to be a bit more specific.

> and how can I get the last substring which is

> "show"?

>

> Thanks

Split it on white spaces and the last element in the returned array is "show".

prometheuzza at 2007-7-12 22:10:53 > top of Java-index,Java Essentials,Java Programming...
# 2
I am going to locate this line by searching the last substring is "show".if((s.endsWith("show"))==true)right or wrong?
ardmorea at 2007-7-12 22:10:53 > top of Java-index,Java Essentials,Java Programming...
# 3
> I am going to locate this line by searching the last> substring is "show".> if((s.endsWith("show"))==true)> right or wrong?Those kind of questions can be best answered by giving it a try.
prometheuzza at 2007-7-12 22:10:53 > top of Java-index,Java Essentials,Java Programming...
# 4
I got it.but how to get the substring within the bracks.I have no idea.
ardmorea at 2007-7-12 22:10:53 > top of Java-index,Java Essentials,Java Programming...
# 5
I still haven't the faintest clue what you're trying to do.
jverda at 2007-7-12 22:10:53 > top of Java-index,Java Essentials,Java Programming...
# 6
I mean ifString s1="42.0000 702.0000 moveto ( 6 fuel - 4.0%u235,3.35%gd2o3) show";I want to get Strng s2=6 fuel - 4.0%u235,3.35%gd2o3;
ardmorea at 2007-7-12 22:10:53 > top of Java-index,Java Essentials,Java Programming...
# 7
I think you could do that with a simpleString s2 = s1.substring(s1.indexOf('(')+1,s1.lastIndexOf(')'));(You will have to remove the spaces before the starting , perhaps by using the trim() method of StringBuffer)
Overkilla at 2007-7-12 22:10:53 > top of Java-index,Java Essentials,Java Programming...
# 8

So you want everything inside the parentheses?

Can there be other parens inside those--escaped or nested?

Can there be other parens on the line outside those, and if so, what do you want to get?

Will all inputs have parens, or will some have none?

You have to be very specific. Just providing one example isn't enough.

jverda at 2007-7-12 22:10:53 > top of Java-index,Java Essentials,Java Programming...