Page 1 of 1
Simple Regex question
Posted: Wed Feb 25, 2009 12:11 pm
by ChrisF79
Greetings:
I'm trying to do a regex on the exprsesion "Foreclosed (REO):</td><td width=240 align=left valign=top>Yes</td>" and trying to capture the word "Yes"
It is always in that format so it should be very easy.
I tried:
Code: Select all
$regex = "/Foreclosed (REO):<\/td><td width=240 align=left valign=top>(.+?)</"
That's what I use to capture other table cells and it works great except this one has the ( character in the description "(REO)" and I think that's what is throwing me off.
Hopefully someone can help!
Thanks,
Chris
Re: Simple Regex question
Posted: Wed Feb 25, 2009 12:57 pm
by pickle
"(" & ")" are special characters, you'll need to escape them with "\".
Your pattern is overly complex though. This works for me: /top>(.*)</
Re: Simple Regex question
Posted: Wed Feb 25, 2009 1:06 pm
by ChrisF79
pickle wrote:"(" & ")" are special characters, you'll need to escape them with "\".
Your pattern is overly complex though. This works for me: /top>(.*)</
Well, I tried escaping them with \ and that didn't work either for some reason. And as far as it being overly complex, it has to be because there are literally 200+ fields in this table and they almost all have the valign="top" part at the end. I definitely need to use "Foreclosed (REO)" somewhere in the expression.
Thanks though.
Re: Simple Regex question
Posted: Wed Feb 25, 2009 3:34 pm
by prometheuzz
ChrisF79 wrote:pickle wrote:"(" & ")" are special characters, you'll need to escape them with "\".
Your pattern is overly complex though. This works for me: /top>(.*)</
Well, I tried escaping them with \ and that didn't work either for some reason. And as far as it being overly complex, it has to be because there are literally 200+ fields in this table and they almost all have the valign="top" part at the end. I definitely need to use "Foreclosed (REO)" somewhere in the expression.
Thanks though.
Try posting the actual data you're testing your regex against, and also post the regex you're using of course.
Just saying "it didn't work either" isn't nowhere near specific enough for others to be able to help you.
Good luck.