Help with a Regex query
-
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 ácidoBut 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.
-
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!
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