I iam trying to convert my data from this form e.x 12hju 1002 to ,("1002") and ,("12hju").
How can i suround my data with this ,("") between "" is my data .
Asked
Active
Viewed 61 times
-3
Wiktor Stribiżew
- 607,720
- 39
- 448
- 563
George Kontonikolaou
- 109
- 4
- 15
-
2Possible duplicate of [Learning Regular Expressions](http://stackoverflow.com/questions/4736/learning-regular-expressions) – Biffen Jan 17 '17 at 09:23
-
1Are there always two "words" separated by a comma. Do you really want to invert the 2? Please add some sample cases and expected result. – Toto Jan 17 '17 at 09:27
-
no the comma is not exist my fault – George Kontonikolaou Jan 17 '17 at 09:51
-
Ok, no comma. What about other question? do you want to have the result on one line, 2 lines, ..? – Toto Jan 17 '17 at 10:06
-
this is going for a database entry so thats why i need my data to have the syntax ... so lines iits ok – George Kontonikolaou Jan 17 '17 at 10:10
3 Answers
0
You can replace all the , with "),(" and then add the (" in the beginning and ") at the end manually.
Amita
- 944
- 1
- 8
- 20
0
A regex as ([\d\w]+),([\d]+) and replace with ,\("\2"\),\("\1"\) will do exactly what you want for your single data entry.
You'll likely need to tune the regex to the entire set.
SaeX
- 17,240
- 16
- 77
- 97
0
- CtrlH
- Find what:
^(\S+),(\S+) - Replace with:
\("$2"\),\("$1"\) - Replace all
Explanation:
^ : start of string
(\S) : group 1, 1 or more non space
\s : a space
(\S) : group 2, 1 or more non space
Note: with Npp, the parenthesis have to be escaped in the replacement.
Toto
- 89,455
- 62
- 89
- 125