Hi,
I am having difficulty groking this regex stuff. I have a string:
"SomeStuff D: Drive is full"
In perl I can do something like if (my $var =~ /\s{1}.:\s/) { ...} where I can check the string to see if there is any occurance of space-anyletter-colon-space
I am trying to do the same in java.. I have...
Pattern p1 = Pattern.compile("\\s\\w:\\s");
Matcher m1 = p1.matcher(myString);
if (m1.matches()) {
System.out.println("MATCH FOUND:" + m1.group(1));
System.out.println("MATCH FOUND:" + m1.group(2));
}
else {
System.out.println("NO MATCH FOUND");
}
This does NOT work.. Can any-one tell me where I am going wrong?
In group(1) I am looking for "SomeStuff" and in group(2) I am looking for "D: Drive is full"
Many thanks
AcidHawk
----
Of All the things I've lost in my life it's my mind I miss the most.
I am having difficulty groking this regex stuff. I have a string:
"SomeStuff D: Drive is full"
In perl I can do something like if (my $var =~ /\s{1}.:\s/) { ...} where I can check the string to see if there is any occurance of space-anyletter-colon-space
I am trying to do the same in java.. I have...
Pattern p1 = Pattern.compile("\\s\\w:\\s");
Matcher m1 = p1.matcher(myString);
if (m1.matches()) {
System.out.println("MATCH FOUND:" + m1.group(1));
System.out.println("MATCH FOUND:" + m1.group(2));
}
else {
System.out.println("NO MATCH FOUND");
}
This does NOT work.. Can any-one tell me where I am going wrong?
In group(1) I am looking for "SomeStuff" and in group(2) I am looking for "D: Drive is full"
Many thanks
AcidHawk
----
Of All the things I've lost in my life it's my mind I miss the most.