Community
    • Login

    Help with a Regex query

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    2 Posts 1 Posters 659 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Kyllom HanK
      Kyllom Han
      last edited by

      Hi there!

      I’ve understand that I can do multiple search&replace queries in this way:

      Search: (á)|(é)|(í)|(ó)|(ú)
      Replace: (?1Á)(?2É)(?3Í)(?4Ó)(?5Ú)

      Example:

      Before: árbol ácido
      After: Árbol ácido

      But how can I use this method if I need to add a precondition, such as line start and some punctuation before it?

      I’ve tried:

      Search: (^[—¿¡«]*?)[(á)|(é)|(í)|(ó)|(ú)] => Works!
      Replace: \1(?2Á)(?3É)(?4Í)(?5Ó)(?6Ú) => Doesn’t work…

      Example:

      Before: —¿árbol ácido?
      After: —¿rbol ácido?

      Any help?

      Regards.

      1 Reply Last reply Reply Quote 0
      • Kyllom HanK
        Kyllom Han
        last edited by

        I answer to myself.

        As Sebastias Proske told me, the solution is ‘to use a non-capturing group for mere grouping purpose, character class is the wrong tool here’.

        Search: (^[—¿¡«]*?)(?:(á)|(é)|(í)|(ó)|(ú))
        Replace: \1(?2Á)(?3É)(?4Í)(?5Ó)(?6Ú)

        Example:

        Before: —¿árbol ácido?
        After: —¿Árbol ácido?

        Regards!

        1 Reply Last reply Reply Quote 3
        • First post
          Last post
        The Community of users of the Notepad++ text editor.
        Powered by NodeBB | Contributors