How to put word between the symbols?
-
i want put word between the symbols in notepad++ (regex) for example i have this list of symbols:
!@#!@#
#@!#@!
#$%#$%
%$#%$#and i want put (word) between the previous symbols for example:
!@#word!@#
#@!word#@!
#$%word#$%
%$#word%$#
what regex can help me? -
Hello @abolfazl-yaasi,
After examination of your list of symbols, I noticed that each line is made of three symbols, which are repeated ! So, I propose a regex, which includes
a word / string / sentence
, surrounded by a same list ofcharacters / symbols
, before and after :-))So, given, for instance, the original list, below :
!@#!@# #@!#@! !@#$%!@#$% testtest #$%#$% &:&: %$#%$#
the following regex S/R :
SEARCH
(?-s)^(.+)\1$
REPLACE
\1Whatever you want\1
would change the above text, as below :
!@#Whatever you want!@# #@!Whatever you want#@! !@#$%Whatever you want!@#$% testWhatever you wanttest #$%Whatever you want#$% &:Whatever you want&: %$#Whatever you want%$#
Notes :
-
As usual, the
(?-s)
part means that thedot
meta-character matches any single standard character, only ! -
Then, between the two locations, beginning of current line (
^
) and end of current line ($
) : -
The regex engine is searching for any string, of any length, immediately repeated (
(.+)\1
) -
Note that the first string, embedded in parentheses, is stored as group 1, and must be present, right after, because of the back-reference (
\1
) to group 1 -
Finally, in replacement, the string
Whatever you want
is, simply, inserted, between these two identical strings.
Best Regards,
guy038
-
-
-
@abolfazl-yaasi Thanks so much for posting a screen shot! That really helped to tell what was happening. You need to have the Regular expression selected at the bottom left of the dialog, instead of Extended.