I must apologize beforehand as this is most likely a very silly conceptual mistake on my part but i am stuck with a regexp to match a line in an in/out-put file, the line would read:
random stuff 123.4: {OR} random stuff 1234.5
I want to do the following to that line:
while ((c_line = c_reader.readLine()) != null) {
System.out.println("Entering RegExp loop\n");
String regline1 = "\.\\d{3}\.\\d\\:";
if (c_line.endsWith (regline1)) {
/* read value and next few lines into buffer */
}
}
If i am not mistaking my regexp should match [Any character] (this to make sure i catch both the 3 and 4 digit values (before the comma) -> [3 digits], literal [.] and again [digit]. Sadly i can’t get this matching to do what i am expecting however.
If Anyone can tell me where i am making the (conceptual) mistake, that would be greatly appreciated.
Kind Regards,
Bas Jansen
The endsWith method of the String class looks for a string and not a pattern at the end of another string.