#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2012
    Posts
    2
    Rep Power
    0

    How to search and replace an expression by another when using Regex in Notepad++


    Hi,

    In a directory of html files, several files contain the following chain :
    <li><font size="2">xxxxxxxxxx</font></li>
    where xxxxxxxxxx is a chain which can vary from 10 to 100 characters
    I would like to replace
    <li><font size="2">xxxxxxxxxx</font></li>
    by
    <li>xxxxxxxxxx</li>

    When using the Serach and Replace function of Notepād++, is there a way to make such replacemnt ?

    Thank you in advance for any help in this matter.

    Patrick
  2. #2
  3. Turn left at the third duck
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2011
    Location
    Nelson, NZ
    Posts
    112
    Rep Power
    93
    Hi patrmich,

    I don't know about Notepad++ (I've heard that its regex capabilities are poor). In EditPadPro (which is regex-friendly) you can use this:

    Search:
    Code:
    <li><font size="2">((.(?!/font))*)</font></li>
    Replace:
    Code:
    <li>\1</li>
    This uses a negative lookahead, which N++ may not support.

    If you know for sure that there is not going to be another tag inside the font tag, then you can use something simpler that will work with a more primitive regex engine:
    Search:
    Code:
    <li><font size="2">([^<]+)</font></li>
    Replace:
    Code:
    <li>\1</li>
    Please let us if one of those works.

IMN logo majestic logo threadwatch logo seochat tools logo