Regex string replacement in Notepad++ -


i have following format in file:

011890111,mfcd00005493 

i need turn of lines into:

update [dbname].iwfs_part_search_tb set mdl_number='mfcd00005493' condensed_part_number = '011890111'; 

i don't know of way can use regex within notepad++ take matches , wrap matches , use them within want replace them rather replacing entire match. can me out here?

try this:

find what: ([0-9]+),([a-z]+[0-9]+)
replace with: update [dbname].iwfs_part_search_tb set mdl_number='$2' condensed_part_number = '$1';

then make sure regular expression checked.

what happening?

([0-9]+) - paranthesis signify "capture group", [0-9]+ means "one or more" of number.
, - comma, not in capture group or anything... comma
([a-z]+[0-9]+) - capture group, contains 1 or more capital letters followed 1 or more numbers.

the "capture groups" above can used within "replace with" field in notepad++ using $ followed index of group. first group ($1) group of numbers existing before comma while second group ($2) group of letters , numbers following comma.

tested:

011890111,mfcd00005493 011891232,mdan00032492 011853233,mfcd00005444 011892121,mfcd01233212 011812341,maas00005493 

becomes:

update [dbname].iwfs_part_search_tb set mdl_number='mfcd00005493' condensed_part_number = '011890111'; update [dbname].iwfs_part_search_tb set mdl_number='mdan00032492' condensed_part_number = '011891232'; update [dbname].iwfs_part_search_tb set mdl_number='mfcd00005444' condensed_part_number = '011853233'; update [dbname].iwfs_part_search_tb set mdl_number='mfcd01233212' condensed_part_number = '011892121'; update [dbname].iwfs_part_search_tb set mdl_number='maas00005493' condensed_part_number = '011812341'; 

Comments

Popular posts from this blog

curl - PHP fsockopen help required -

HTTP/1.0 407 Proxy Authentication Required PHP -

c# - Resource not found error -