Reputation: 772
I have this string :
[This regex tester evaluates JavaScript regular expressions]
when i match it by this \[(.*?)]
, it match but when i click enter like this :
[This regex tester
evaluates JavaScript regular expressions]
the match not work , how to ignore <br>
?
Upvotes: 1
Views: 570
Reputation: 70732
The following should suffice.
\[([^\]]*)\]
See live demo
Note: If you have multiple strings like the following in a multi-line string, you could also use the following:
\[([\S\s]*)\]
Or add the non-greedy ?
making it match the least amount possible.
\[([\S\s]*?)\]
See live demo
Upvotes: 3
Reputation: 785651
You don't have <tr>
in the line, it is just a new line in between which .*
will not match.
Try this regex to match:
\[([\s\S]*)\]
[\s\S]
will match new lines as well since Javascript doesn't have DOTALL (s) flag.
Upvotes: 2