Month: June 2017

Regular expressions

Some handy regular expressions terms

If you want to remove only specific tags from the html, you can use following regular expression. I use it along with PHP storm.

For example here is my sample code

    <a href="/samplelink/5656/565">
        <i class="fa fa-trash-o fa-2x" aria-hidden="true"></i>
    </a>
    <a href="/samplelink/21112/21">
        <i class="fa fa-trash-o fa-2x" aria-hidden="true"></i>
    </a>
    <a href="/samplelink/99/997"> 
        <i class="fa fa-trash-o fa-2x" aria-hidden="true"></i>
    </a>

if you want to replace all a tags

<a href="/samplelink/99/997">

I will use the following code in regular expressions to find

<a href=".*?"\s*[/>]* 

Advertisements