Community
    • Login

    Help with a Regex query

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    2 Posts 1 Posters 818 Views 1 Watching
    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 Offline
      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 Offline
        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

        Hello! It looks like you're interested in this conversation, but you don't have an account yet.

        Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

        With your input, this post could be even better 💗

        Register Login
        • First post
          Last post
        The Community of users of the Notepad++ text editor.
        Powered by NodeBB | Contributors