Hi,
I am trying to find and replace following comma(,) and rest of the line on following three situation of select query and i got struck at the replacement speicification.
1) Line ended with comma(,)
Example: a.column3,
2) Line ended with spaces( ) after comma(,)
Example: a.column,\space\space\space
3) Line ended with comments(--some text spaces) after comma
Example: a.column2, -- comment,
Now i want above three scenarios to be replaced with text just before that comma(,) character.
I could able to find all of them with the following find specification.
Find What: ^\(.*\),[ ]*$\|^\(.*\),[[:blank:]]*--*.*$
Replace with: \1\2
This didn't work well when it finds the string by first expression itself.
I could do this in two search, but i would prefer to do it in single search itself.Please advise me on this....
Thanks
Thamark
How do i replace tagged expression on OR conditional search
Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard
-
- Posts: 2461
- Joined: Sun Mar 02, 2003 9:22 pm
It didn't work
Ben,
I tried following things and it didn't work.
Result should be like
I tried following things and it didn't work.
Tried to do your find and replace for following sample data and it didn't work.Configure | Preferences | Editor
[X] Use POSIX regular expression syntax
It didn't find those string at all. My textpad version is Textpad 4.7.3 : 32-bit version.a.column1,
a.column2,
'',
1, -- comment,
'', -- comment,
'', -- comment,
'', -- comment
Result should be like
Thanks for your reply and i will be looking forward to see update in this regard...a.column1
a.column2
''
1
''
''
''
-
- Posts: 2461
- Joined: Sun Mar 02, 2003 9:22 pm
Hmm i got it wrong somewhere
Ben,
I tried it again and it works perfectly. I think as you mentioned something added when I was copying from web to tool.
Thanks a lot and I never thought of this solution, since I was struck that I should be handling them as individual cases....
By the way do we have any answer for how to replace OR condition cases just curios
I tried it again and it works perfectly. I think as you mentioned something added when I was copying from web to tool.
Thanks a lot and I never thought of this solution, since I was struck that I should be handling them as individual cases....
By the way do we have any answer for how to replace OR condition cases just curios
-
- Posts: 2461
- Joined: Sun Mar 02, 2003 9:22 pm
In the general case you can't do this.
Suppose you have an alternation (a regex with a | in it):
E11 (E12) E13 | E21 (E22) E23
so that, in a replacement, \1 is whatever E12 matches and \2 is whatever E22 matches.
Then if the first alternative ( E11 (E12) E13 ) matches, so that \1 is whatever E12 matches, then \2 simply doesn't exist, and if there is a \2 in the replacement it is included literally.
And if the second alternative ( E21 (E22) E23 ) matches, so that \2 is whatever E22 matches, then \1 simply doesn't exist, and if there is a \1 in the replacement it is included literally.
Suppose you have an alternation (a regex with a | in it):
E11 (E12) E13 | E21 (E22) E23
so that, in a replacement, \1 is whatever E12 matches and \2 is whatever E22 matches.
Then if the first alternative ( E11 (E12) E13 ) matches, so that \1 is whatever E12 matches, then \2 simply doesn't exist, and if there is a \2 in the replacement it is included literally.
And if the second alternative ( E21 (E22) E23 ) matches, so that \2 is whatever E22 matches, then \1 simply doesn't exist, and if there is a \1 in the replacement it is included literally.