Wednesday, 21 August 2013

regex, get the first characters after the line when you find a keyword

regex, get the first characters after the line when you find a keyword

Ive been mashing with regex builders and tutorials and cant figure this
out. I have a keyword which i can find and i need to find the timestamp on
either that same line or the next line.
my text looks something like this
16:51:35.536 This is a bunch of completely random text although it has a
keyword. This keyword is unique
16:51:35.806 This is another line which has all sorts of crap i dont
really care about.
Now what im trying to capture is either the first 8 characters to get the
timestamp ie 16:51:35
so im trying to do something like this
myKeyword_to_find_the_line (.*) ([0-9){2}:[0-9){2}:[0-9){2})
but for whatever reason it gets stuck on that line even if i add /m at the
end or /s or /S
This works on getting to the next line:
([\s\S]*)
so i tried
myKeyword_to_find_the_line ([\s\S]*)(?=[0-9){2}:[0-9){2}:[0-9){2}) but
that didnt work either
Im pretty sure its less complicated than im making it, any ideas

No comments:

Post a Comment