Find and Replace with Regular Expressions (Regex): Software error or inadequate user? :-)
-
Hi,
I have this text:
FIELD ONE
FIELD TWO
FIELD THREEI want to replace “spaces” with “underscores”, but only when the “space” is only one and between words.
I use this Regex:
Find: ([A-Z]) ([A-Z])
Replace: \1_\2If I use buttons with the sequence
Find, Repl&FAgain (1), Repl&FAgain (1), Repl&FAgain (1)
I obtain a strange substitution
FIELD_ONE
FIEL_WO
FIEL_HREEInstead of
FIELD_ONE
FIELD_TWO
FIELD_THREEIt works with button sequence
Find, Replace Rest
or
Find, Repl&FAgain (3)Is it a bug or I misunderstood anything?
Danilo
-
Hello, @Danilo Schembri and All,
Ah, you spoke of the
TextFXplugin behavior ! Seemingly, when doing a step by step replacement, it does not update the values of group1and group2, leaving them empty :-((But, why don’t you perform the native N++ replacement, instead ?
-
Open the Replace dialog (
CTRL + H) -
SEARCH
([A-Z])\x20([A-Z]) -
REPLACE
\1_\2 -
Select the Regular expression` search mode
-
Tick , if necessary, the
Wrap aroundoption -
Click, once, on the
Replace AllOR several times on theReplacebutton
You may use a simple
spacecharacter, instead of the\x20syntaxBest Regards
guy038
-
-
your regex works for me
Find: ([A-Z]) ([A-Z])
Replace: \1_\2
`Search Mode: Regular Expressiongives me
FIELD_ONE
FIELD_TWO
FIELD_THREEif i press replace all (or repeatedly press replace)
@guy038
i think you ment:
REPLACE\1\x5F\2instead of REPLACE\1\x20\2
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