Search code examples
regexnotepad++

How can I delete only a certain group from the links using regular expressions in Notepad++?


I have a lot of files and they have something like this text:

<a class=“table-row” href=“value1/value2”>
. . .
<a class=“table-row” href=“value3/value4">
. . .

How to delete first groups following the href and the slash, using regexp in Notepad++, so that eventually the links look like this:

<a class=“table-row“ href=”value2“>

<a class=”table-row“ href="value4">

Solution

  • You can use this regex (href=")(\w+\/) and replace for $1.

    In Notepad++ you can type CTRL + F and in "Replace" tab set like this:

    enter image description here

    Then click Replace All and all ocurrences will be removed.