mb81 Posted February 3, 2007 Share Posted February 3, 2007 Hey everyone, I am writing my first really hardcore regex and I ran into a problem. What I am doing is trying to parse elements out of a table that is in a standard format. I built the regex from left to right slowly working through each pattern and I got to this point that worked: preg_match("|<tr><td>(\d{2}/\d{2}/\d{0,4})</td><td>(\d{4}\*?)</td><td>([\d\w ]*)</td><td>([\d\w ]*)</td><td>|",$thisfile,$matches); When I added the next section to test for "TBA" or a time (##:## or #:##), shown here: preg_match("|<tr><td>(\d{2}/\d{2}/\d{0,4})</td><td>(\d{4}\*?)</td><td>([\d\w ]*)</td><td>([\d\w ]*)</td><td>(TBA|\d{1:2}))|",$thisfile,$matches); It gave me this error: unknown modifier '\', it doesn't seem to like it after the or '|' operator, I tried to switch them and it didn't like that either, saying the "T" was an unknown modifer. There is nothing in the tutorials that I am referencing that say anything about it. Can someone help? Thanks, Matt Quote Link to comment Share on other sites More sharing options...
effigy Posted February 3, 2007 Share Posted February 3, 2007 You're using a pipe as the delimiter and as the alternation metacharacter. I recommend changing your delimiter to something that is not in regex or your data; perhaps a percent sign. Quote Link to comment Share on other sites More sharing options...
mb81 Posted February 3, 2007 Author Share Posted February 3, 2007 You're using a pipe as the delimiter and as the alternation metacharacter. I recommend changing your delimiter to something that is not in regex or your data; perhaps a percent sign. Good answer - SOLVED! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.