Page 1 of 1
Search for > in column 1
Posted: Wed Sep 03, 2008 10:45 am
by Mach1
Is there any way to search for > followed by a space, but ONLY in column 1 of a file? I have tried various permutations following suggestions in the help file, so far without success.
Regards
Mach1
Posted: Wed Sep 03, 2008 11:47 am
by ACRobin
"^[>[:blank:]]"
The above (minus the quotes) is the regular expression you will need in the Find box (regular expression - ticked).
I am no expert, but seems to work.
Posted: Wed Sep 03, 2008 12:13 pm
by Mach1
I am confused!
I tried your suggestion, but it seemes to find any line starting with a blank. So I played around a bit and found that this works: ^>[>[:blank:]]
I am an absolute beginner on this topic and do not understand what the different elements of the expression signify - but I appear to need BOTH > symbols to get this working.
Can anyone offer a beginners source that gives a little explanation of the syntax?
Thanks.
Posted: Wed Sep 03, 2008 12:18 pm
by ak47wong
ACRobin wrote:"^[>[:blank:]]"
The above (minus the quotes) is the regular expression you will need in the Find box (regular expression - ticked).
This isn't correct. That matches either ">" or a space or a tab at the start of the line, not what Mach1 was asking for.
The correct expression is:
^>_
where _ represents a space.
Make sure "Regular expression" is ticked in the Find dialog.
Andrew
Posted: Wed Sep 03, 2008 12:28 pm
by Mach1
VERY confused now... But the good bnews is that both my own variant of ACRobin's suggestion AND that fro Andrew seem to work....So although I don't understand why - my immediate problem is solved.
Thanks to you both for very prompt (and helpful) responses.
Mach1
Posted: Wed Sep 03, 2008 1:53 pm
by ben_josephs
Your regular expression is incorrect.
^>[>[:blank:]] matches
Code: Select all
^ the beginning of a line
> the literal text: >
[>[:blank:]] either a > or a blank
Thus it matches on lines that begin with with a
>, followed by either a another
> or a blank. So it matches, for example, on lines that begin
>>xxxx
As Andrew suggested, you can use a simple space instead of the cumbersome expression
[:blank:], unless the
> might be followed by a tab instead of a space (in which case
[ \t] is shorter).
There are many regular expression tutorials on the web, and you will find recommendations for some of them if you search this forum.
A standard reference for regular expressions is
Friedl, Jeffrey E F
Mastering Regular Expressions, 3rd ed
O'Reilly, 2006
ISBN: 0-596-52812-4
http://regex.info/
But be aware that the regular expression recogniser used by TextPad is very weak compared with modern tools. So you may get frustrated if you discover a handy trick that works elsewhere but doesn't work in TextPad.
Posted: Wed Sep 03, 2008 2:07 pm
by Mach1
Thanks for the tips. The help you have all provided has been a great asssistance with what was promising otherwise to be an extremely tedious (and probably error-prone) task.
Regards
Mach1
Posted: Wed Sep 03, 2008 3:19 pm
by ben_josephs
You're welcome.
I see that my message might mislead, so I should add a clarification:
[ \t] is equivalent to [[:blank:]] and [> \t] is equivalent to [>[:blank:]].