December 20th, 2013, 08:37 PM
[VB 2008] Regex Using "." to INCLUDE line breaks
I want to start by searching for "strong" and end by searching for "npc" and match everything in between with an unknown number of line breaks. How do I accomplish this? using ".*\n*" doesn't work because it searches for any character and then any number of line breaks. I need them to be combined.
Thank you in advance.
December 20th, 2013, 09:03 PM
Look at the RegexOptions enum. It has an option specifically for that behavior.
Comments on this post
December 20th, 2013, 09:16 PM
My apologies, It's been a while since I've done this and can't seem to make it work.
Still doesn't work. Can you elaborate?
getpost(server + "/pages/raid_result.php?id=145748", "GET", "")
pattern = "strong.*npc.*\r$"
MsgBox(Regex.Match(responseFromServer, pattern, RegexOptions.Multiline).ToString)
December 20th, 2013, 10:11 PM
I have figured it out. It was deceiving because instead of using "Multiline" I actually needed to use "Singleline" which did exactly as I was looking for, it made "." match every character including a new line. Thank you again.
December 20th, 2013, 10:19 PM
Yes, that's it. Multiline means that start- and end-of-string anchors (^ and $) match the beginning and end of every line - as in your input has multiple lines but you want ^ and $ to be even more useful.
Singleline is like saying to treat the entire thing as if it were just the one line - newline characters are just more bytes and dot-all should match them too.
At least that's how I think of it.
December 23rd, 2013, 02:10 PM
I thought enough time had passed to add to your reputation again but it hasn't. In any case thank you again and your explanation definitely helped clear that up for me. I've been on this board for almost a decade and the wonderful people here never cease to amaze me.