Menu

find and replace problem (Capturing Group / Control Character)

Help
2016-03-17
2016-03-17
  • Thomas Christen

    Thomas Christen - 2016-03-17

    Hi all

    First off: Thank you very much for python script. I'm new to Regular Expressions and Python. Everything I needed so far worked :-) ... until now....

    Im trying to do a find and replace as follows:

    editor.rereplace("^<sup>(.*?)</sup>"," \? \1 \n : ")

    Instead of returning the content of the Capturing Group I get a Control Character (SOH) in Notepad++.

    If I perform the find and replace directly in Notepad++ (without Python Script) it works flawlessly.

    What am I missing?

    Thank you very much.

    Tom

     
  • CFrank

    CFrank - 2016-03-17

    Hello Thomas,

    you are correct, npp is using \1 notation internally where as boost regular expression mentions $1 to be used. See here for more information about regex replace part and this site about the search part.

    Cheers
    Claudia

     

    Last edit: CFrank 2016-03-17
  • Henri Mesquida

    Henri Mesquida - 2017-04-18

    Hello @CFranck, so what is the solution because same problem :(
    Make multiple search/replace "à la main" whitout automation?
    Thank you in advance.
    Henri
    PS. Needed to change the order of the columns and delete some of them from a CSV extract.

    Search = (".*?"),(".*?"),(".*?"),(".*?"),(".*?"),(".*?"),(".*?"),(".*?"),(.*)
    replace = \4,\1,\5,\7,\6,\9
    
     
  • CFrank

    CFrank - 2017-04-18

    so what is the solution

    Escaping. Python uses the backslash internally as well, so you need to do things like
    \\4,\\1...

    Cheers
    Claudia

     

    Last edit: CFrank 2017-04-18

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.