1
What would be the expression of the preg_match to get the text "exit" within the following tag?
<a href="/logout" role="menuitem">
<i class="icon-key"></i> Sair
</a>
1
What would be the expression of the preg_match to get the text "exit" within the following tag?
<a href="/logout" role="menuitem">
<i class="icon-key"></i> Sair
</a>
1
The expression would look like this:
<a href="\/logout" role="menuitem">[\s]+<i class="icon-key"><\/i> ([a-zA-Z]+)[\s]+<\/a>
Browser other questions tagged preg-match
You are not signed in. Login or sign up in order to post.
Regular expression to treat HTML is not the best solution. What language do you want to do this? PHP? If so, use the class
DOMDocument
.– Woss
As we have no information on where, how or why the OP needs to do this, use the
DOMDocument
just for that it would be– Bruno Augusto
@Brunoaugusto in this case, you wouldn’t even know it’s an ant, so taking a cannon would be appropriate. I say this because if the HTML varies in any detail, the regular expression is invalidated and the application stops working. And for an HTML to change is very easy...
– Woss
David did not throw any stone at Goliath. The most suitable tool for the task was chosen. For something so simple Simplexml spare
– Bruno Augusto