Page 1 of 1

Reg Exp to find Number String

Posted: Sun Mar 22, 2009 6:59 am
by burtonfigg
Is it possible to use TextPad to search through a 3,000 line text document, and find lines including for example:

D[followed by a number] ICT e.g. D234 ICT

I don't need to run this search as well, but would also like to run another search for:

[number] bikes, e.g. 123 Bikes

The position of these strings is not consistent within each line of text.

One more search I'd like to do - would it be possible to run a search for:

**ride**
**decorating**
**anything**


Where there is one word between the asterisks - i.e. there is actually a string with **ride** and I'd like to be able to run a search for that string...

And ideally, it'd be useful to modify that search as well, to find text strings where there are any lines with **anything** where 'anything' can be any word, as long as it is wrapped in 2 asterisks.

The lines of text are from an SQL file export of a MySQL table.

Sorry for asking for so much.

Thanks

Posted: Sun Mar 22, 2009 3:21 pm
by Bob Hansen
To find D followed by a number
Find what: D[0-9]+_

-------------------------------
To find a number followed by something else
Find what: _[0-9]+_

-------------------------------
To find anything surrounded by double asterisks
Find what: \*\*.*\*\*

--------------------------------
Note that in Searches above, that "_" is a space character

Use the following settings:
-----------------------------------------
[X] Regular expression
-----------------------------------------
Configure | Preferences | Editor
[X] Use POSIX regular expression syntax
-----------------------------------------

Posted: Sun Mar 22, 2009 5:34 pm
by ben_josephs
And to find text like D234 ICT use
D[0-9]+ ICT

To find text like 123 Bikes use
[0-9]+ Bikes

To find any of
**ride**
**decorating**
**anything**
use
\*\*(ride|decorating|anything)\*\*

To find any word wrapped in 2 asterisks use
\*\*[a-z]+\*\*

For all of these select Regular expression.

The regex with parentheses assumes you are using Posix regular expression syntax:
Configure | Preferences | Editor

[X] Use POSIX regular expression syntax