Hi,
I want to find out the pattern as follows
text = "XYZ 34 N TO 763427894"
XYZ and 'N TO' are fixed. only numbers can change. please help me to
find regex for this text.
Thanks in advance
DF
TechBookReport - 19 Jul 2006 10:33 GMT
> Hi,
>
[quoted text clipped - 7 lines]
> Thanks in advance
> DF
What have you tried so far?

Signature
TechBookReport Java - http://www.techbookreport.com/JavaIndex.html
Oliver Wong - 19 Jul 2006 15:44 GMT
> Hi,
>
[quoted text clipped - 4 lines]
> XYZ and 'N TO' are fixed. only numbers can change. please help me to
> find regex for this text.
If you're unable to come up with the regexes, why don't you fall back to
a simpler solution? For example, scanning the string until you find a digit?
- Oliver
Frank Langelage - 19 Jul 2006 21:18 GMT
> Hi,
>
[quoted text clipped - 7 lines]
> Thanks in advance
> DF
Did not try it but "^XYZ \\d+ N TO \\d+$" is near to the final answer.
IchBin - 19 Jul 2006 21:21 GMT
> Hi,
>
[quoted text clipped - 7 lines]
> Thanks in advance
> DF
There are a lot of ways you could do this.
String text = "XYZ 34 N TO 763427894";
//
// split on whitespace character "\\s" or [ \t\n\x0B\f\r]
String values[] = text.split("\\s");
//
// or what ever numeric type you want
int number1 = Integer.parseInt(values[1]);
int number2 = Integer.parseInt(values[4]);
Or you could check for non-digit
//
// split on A non-digit: "\\D" or [^0-9]
String values[] = text.split("[^0-9]");
Thanks in Advance...
IchBin, Pocono Lake, Pa, USA http://weconsultants.phpnet.us
__________________________________________________________________________
'If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor, Regular Guy (1952-)