Skip to main content
added 482 characters in body
Source Link
Robin
  • 9.6k
  • 3
  • 37
  • 45

If the 122545;bmwx3;new; part is not fixed

In three steps:

  • Get to red,black,white,pink#LIMIT#122545;bmwx3;new;: replace (.*;)([^;]*) with \2#LIMIT#\1

  • Create the 122545;bmwx3;new;red stings: replace

      (\w+)(?:,|(?=#LIMIT#))(?=.*#LIMIT#(.*))
    

    with \2\1\n (see demo)

  • Remove the #LIMIT#... lines: replace ^#LIMIT#.* with an empty string


If the 122545;bmwx3;new; part is fixed

@hjpotter's idea seems pretty cool, if the 122545;bmwx3;new; part is fixed you just new to replace , with

\n122545;bmwx3;new;
 

Then replaceWhat's left

Replace

^(\w*);(\w*);(\w*);(\w*)$

with

INSERT INTO myTable VALUES ("$1""\1", "$2""\2", "$3""\3", "$4""\4")

You're good to go !

@hjpotter's idea seems pretty cool, if the 122545;bmwx3;new; part is fixed you just new to replace , with

\n122545;bmwx3;new;

Then replace

^(\w*);(\w*);(\w*);(\w*)$

with

INSERT INTO myTable VALUES ("$1", "$2", "$3", "$4")

If the 122545;bmwx3;new; part is not fixed

In three steps:

  • Get to red,black,white,pink#LIMIT#122545;bmwx3;new;: replace (.*;)([^;]*) with \2#LIMIT#\1

  • Create the 122545;bmwx3;new;red stings: replace

      (\w+)(?:,|(?=#LIMIT#))(?=.*#LIMIT#(.*))
    

    with \2\1\n (see demo)

  • Remove the #LIMIT#... lines: replace ^#LIMIT#.* with an empty string


If the 122545;bmwx3;new; part is fixed

@hjpotter's idea seems pretty cool, you just new to replace , with

\n122545;bmwx3;new;
 

What's left

Replace

^(\w*);(\w*);(\w*);(\w*)$

with

INSERT INTO myTable VALUES ("\1", "\2", "\3", "\4")

You're good to go !

Source Link
Robin
  • 9.6k
  • 3
  • 37
  • 45

@hjpotter's idea seems pretty cool, if the 122545;bmwx3;new; part is fixed you just new to replace , with

\n122545;bmwx3;new;

Then replace

^(\w*);(\w*);(\w*);(\w*)$

with

INSERT INTO myTable VALUES ("$1", "$2", "$3", "$4")