Find lines that begin with certain string/words

General questions about using TextPad

Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard

Post Reply
elcaro
Posts: 7
Joined: Fri May 25, 2012 9:38 pm

Find lines that begin with certain string/words

Post by elcaro »

Using Textpad 7.0.9 (32-bit)

I want to find lines that begin with certain string/words. There might be white spaces or tabs before that string but nothing else. Basically if that lines begins with that string, I want to find it. I thought '^' will work, but it didn't :-(
ben_josephs
Posts: 2461
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

Search | Find... (<F8>):
Find what: ^\h*Your string

[X] Regular expression
But if Your string contains special characters, such as \, (, ), [, ], {, }, *, +, you'll have to either quote those special characters individually using backslashes or square brackets, or quote the whole string with \Q...\E, like this:

^\h*\QYour string containing special characters: ( [ { \ * + } ] )\E
elcaro
Posts: 7
Joined: Fri May 25, 2012 9:38 pm

Post by elcaro »

Thanks much ben_josephs!

Would \h take care of tabs too?
ben_josephs
Posts: 2461
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

In TextPad's help, in the section Reference Information | Regular Expressions, in the table under the heading "Single character" character classes, is this entry:
\h ... Horizontal whitespace
elcaro
Posts: 7
Joined: Fri May 25, 2012 9:38 pm

Post by elcaro »

Thanks again ben_josephs!
Post Reply