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.
    • abolfazl yaasiA
      abolfazl yaasi
      last edited by

      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
      • guy038G
        guy038
        last edited by guy038

        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

        abolfazl yaasiA 1 Reply Last reply Reply Quote 0
        • abolfazl yaasiA
          abolfazl yaasi @guy038
          last edited by

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

          mediafire

          1 Reply Last reply Reply Quote 0
          • glennfromiowaG
            glennfromiowa
            last edited by glennfromiowa

            @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
            • First post
              Last post
            The Community of users of the Notepad++ text editor.
            Powered by NodeBB | Contributors