Reputation: 1849
Good afternoon
I am testing my Regular Expression on regex101.com site. Regular Expression:
<button[^<]*>.*[\s\S]*<\/button>|
<iframe[^<>]*\/>|
<tr>[^<td>]*<\/tr>
Test Text
<table width="30px">
<P>Teste</p><iframe src="teste" /><p>Test</p>
<div><span>Teste Regex</span></div>
<p>Test</p><button onclick="myFunction()">Click me</button>
<table>
<tr><td>34</td></tr>>
</table>
Why only the <button[^<]*>.*[\s\S]*<\/button>
code is matched ?
If i clear this part of the regular expression and stay only with this:
<iframe[^<>]*\/>|
<tr>[^<td>]*<\/tr>
Only the <iframe..
is matched
Why is this happen and how can I fix it ?
Upvotes: 0
Views: 148
Reputation: 31045
You have to remove the new lines before your OR and also set the G (global flag).
Upvotes: 1