• Login
Community
  • Login

How to put word between the symbols?

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
regex
4 Posts 3 Posters 3.4k Views
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.
  • A
    abolfazl yaasi
    last edited by Aug 12, 2017, 6:26 PM

    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?

    1 Reply Last reply Reply Quote 0
    • G
      guy038
      last edited by guy038 Aug 12, 2017, 11:26 PM Aug 12, 2017, 11:23 PM

      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 of characters / 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 the dot 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

      A 1 Reply Last reply Aug 13, 2017, 4:37 AM Reply Quote 0
      • A
        abolfazl yaasi @guy038
        last edited by Aug 13, 2017, 4:37 AM

        @guy038
        i tried that but result me notice
        see picture that i uploaded on this host:

        mediafire

        1 Reply Last reply Reply Quote 0
        • G
          glennfromiowa
          last edited by glennfromiowa Aug 14, 2017, 12:15 AM Aug 14, 2017, 12:15 AM

          @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.

          1 Reply Last reply Reply Quote 0
          1 out of 4
          • First post
            1/4
            Last post
          The Community of users of the Notepad++ text editor.
          Powered by NodeBB | Contributors