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
TextFX
plugin behavior ! Seemingly, when doing a step by step replacement, it does not update the values of group1
and 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 around
option -
Click, once, on the
Replace All
OR several times on theReplace
button
You may use a simple
space
character, instead of the\x20
syntaxBest 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\2
instead of REPLACE\1\x20\2