0

I'm definitely no expert on regular expressions, but this one seems simple enough, yet it just doesn't wanna do what I thought it should do.

I have a bunch of HTML and plain text documents. Within the docs there are sometimes a reference to a drive "f:". I need to detect these and turn them into an IP address instead.

I do this with this regular expression in a preg_replace

/f:\\((.+))(?:$|\n|<)/i

Start at f:\ and stop at end of string or new line or a less than sign. It seems to handle end of string and new line as it should, but it just completely ignores the less than sign, thus included HTML tags in the selection.

I've tried escaping the less than sign, and also tried other approaches such as /f:\\((.+))([$\n<]/i, but the result is the same.

What am I missing?

mr_lou
  • 1,881
  • 2
  • 13
  • 25

0 Answers0