Regular Expression parsing URL
Posted on 2007-08-02
This should be a quick on. I have a pattern that breaks a HTML hyperlink into the address and the display text:
This may not be ideal, but it works well enough for me with one exception. Most of the urls I'm parsing are formatted:
This works out fine. Two groups return, the first with the address (/cgi-bin/show_case_doc?2,576695,,,) and the second with the displayed text (2).
However, there are some URLs that leave out the quotation marks:
For some reason, when this happens the displayed text (2) returns fine, but the address truncates the last comma (/cgi-bin/show_case_doc?2,576695,,) and I can't figure out why. Granted, I'm new to regular expressions.
I'm sure it's some stupid little thing I missed, but I'm at a loss.