Page 1 of 1
Search - Replace using regular expression
Posted: Wed Apr 21, 2010 4:31 am
by kchandr
Hi,
I have few column name like below :
col1
col2
col3
Now I want the output like :
a.col1 / b.col1
a.col2 / b.col2
a.col3 / b.col3
I am trying to achieve it in text editor like Editplus which support regular expression.
Can anyone please help me to achieve the result here.
Regards,
Koushik
Re: Search - Replace using regular expression
Posted: Wed Apr 21, 2010 1:38 pm
by Christopher
I am not exactly sure, but it should be something like "s/^.*$/a\.& \/ b\.&/g"
Re: Search - Replace using regular expression
Posted: Wed Apr 21, 2010 3:26 pm
by ridgerunner
Try this:
Code: Select all
Search pattern:
^([A-Za-z0-9]+)$
Replacement string:
a.\1 / b.\1
Re: Search - Replace using regular expression
Posted: Wed Apr 21, 2010 9:38 pm
by kchandr
Thanks a lot. The following solution works perfectly.
Search pattern:
^([A-Za-z0-9]+)$
Replacement string:
a.\1 / b.\1
Regards,
Koushik
Re: Search - Replace using regular expression
Posted: Thu Apr 22, 2010 4:55 am
by kchandr
I stuck with another problem. I have the following strings :
src_sys_nm in ('SAP-AP0')
src_sys_nm in ('SAP-AP0','SAP-AP0-PRG')
src_sys_nm in ('SAP-EP0','SAP-AP0','SAP-EP1')
src_sys_nm in ('SAP-EP0','SAP-EP1','SAP-AP0')
And I want to get (basically all SAP-AP0* will be replaced by SAP-AP0*,SBI-NBP*):
src_sys_nm in ('SAP-AP0','SBI-NBP')
src_sys_nm in ('SAP-AP0','SBI-NBP','SAP-AP0-PRG','SBI-NBP-PRG')
src_sys_nm in ('SAP-EP0','SAP-AP0','SBI-NBP','SAP-EP1')
src_sys_nm in ('SAP-EP0','SAP-EP1','SAP-AP0','SBI-NBP')
I can achieve it using the search string : (SAP-AP0)(-)*([a-z|A-Z|0-9]*) and the replacement string : SAP-AP0\2\3','SBI-NBP\2\3
But If I have the strings like below :
src_sys_nm in ('SAP-AP0','SBI-NBP') --- for this string SBI-NBP is already there
src_sys_nm in ('SAP-AP0','SAP-AP0-PRG')
src_sys_nm in ('SAP-EP0','SAP-AP0','SAP-EP1')
src_sys_nm in ('SAP-EP0','SAP-EP1','SAP-AP0')
So for the above case I don't want to replace in the 1st occurrence as SBI-NBP is already there but want to replace the next 3 lines means I just want to skip the 1st line here.
Can you please suggest how should I achieve this.
Regards
Koushik