Community
    • Login

    Regular Expression: Duplicate String to the first ';' on every line

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    2 Posts 2 Posters 1.8k Views 2 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.
    • CuerdaC Offline
      Cuerda
      last edited by

      Hi All,

      I need a regular expression to duplicate text on each line from beginning to the first ;

      Example:

      “ahpardos@gmail.com”;“EFCD2827”;1
      “garbibus@yahoo.es”;“F5449245”;0

      Result I need:

      “ahpardos@gmail.com”;"ahpardos@gmail.com";“EFCD2827”;1
      “garbibus@yahoo.es”;"garbibus@yahoo.es";“F5449245”;0

      I’ve tried a lot of ideas but nothing works.

      Thanks in advance.

      Scott SumnerS 1 Reply Last reply Reply Quote 1
      • Scott SumnerS Offline
        Scott Sumner @Cuerda
        last edited by

        @Cuerda

        It might give some insight into where you are going wrong by explaining what you’ve tried already…knowing this maybe we could offer hints about why it didn’t work…with this maybe you could maximize your learning. :-)

        However, this seems to meet the spec provided:

        Find-what zone: ^"[^"]+";
        Replace-with zone: $0$0

        Explanation of the Regular Expression (brought to you by RegexBuddy)

        FIND:

        Assert position at the beginning of a line (at beginning of the string or after a line break character) (carriage return and line feed, form feed) «^»
        Match the character “"” literally «"»
        Match any character that is NOT a “"” «[^"]+»
           Between one and unlimited times, as many times as possible, giving back as needed (greedy) «+»
        Match the character string “";” literally «";»
        

        REPLACE:

        Insert the whole regular expression match «$0»
        Insert the whole regular expression match «$0»
        

        …And here’s some subliminal messages for ya:
        IF YOU USE REGEX, BUY A RegexBuddy LICENSE
        IF YOU USE REGEX, BUY A RegexBuddy LICENSE
        IF YOU USE REGEX, BUY A RegexBuddy LICENSE
        …OK, enough of that…

        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