Regular Expression: Duplicate String to the first ';' on every line
-
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”;0Result I need:
“ahpardos@gmail.com”;"ahpardos@gmail.com";“EFCD2827”;1
“garbibus@yahoo.es”;"garbibus@yahoo.es";“F5449245”;0I’ve tried a lot of ideas but nothing works.
Thanks in advance.
-
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…