Navigation

    Community

    • Login
    • Search
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

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

    Help wanted · · · – – – · · ·
    2
    2
    1205
    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.
    • Cuerda
      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 Sumner 1 Reply Last reply Reply Quote 1
      • Scott Sumner
        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
        • First post
          Last post
        Copyright © 2014 NodeBB Forums | Contributors