0

I came across the following RE recently:

(?:<div class="something[^>]+?>[^]+<span class="somethingelse">([\d.])+|<div id="anotherthing[^"]+" class="[^"]*andanother)

The set [^] is valid in JavaScript but not in PCRE. My understanding of it is that it will match "anything not in the set". Since the set is empty, it must be matching anything (one or more times). So why would someone use [^]+ rather than simply .+ ? Is there some very subtle difference, perhaps to do with line endings?

Mark Bradley
  • 440
  • 4
  • 10

1 Answers1

2

. does not match line endings by default. You can enable the DOTALL option (e.g /.+/s) to make it match line endings as well.