Community
    • Login

    How to put word between the symbols?

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    regex
    4 Posts 3 Posters 3.7k Views 1 Watching
    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 Offline
      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 Offline
        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 Offline
          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 Offline
            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

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