shortened character sets

General questions about using TextPad

Moderators: AmigoJack, bbadmin, helios, MudGuard

Post Reply
anandm
Posts: 3
Joined: Wed Jul 02, 2008 8:08 pm

shortened character sets

Post by anandm »

I am learning REGEX and this tutorial I am using says that in place of commonly used character sets I can use short forms
eg:- \d is short for [0-9]
OR
\w stands for "word character", usually [A-Za-z0-9_]

This doesn't seem to work for me in Textpad. I have tried with the Posix option both on and off.


Any ideas?
Thanks
User avatar
Bob Hansen
Posts: 1516
Joined: Sun Mar 02, 2003 8:15 pm
Location: Salem, NH
Contact:

Post by Bob Hansen »

The RegEx syntax used n TextPad is different from the one used in your tutorial.

Check out the TextPad Halp for "Regular Expressions" and "How To Use Regular Expressions".
Hope this was helpful.............good luck,
Bob
User avatar
talleyrand
Posts: 624
Joined: Mon Jul 21, 2003 6:56 pm
Location: Kansas City, MO, USA
Contact:

Post by talleyrand »

The regular expression engine in TextPad doesn't have as much power as you will find in modern libraries. I tend to use a site like http://regexlib.com/RETester.aspx as a harness for testing my expressions


From the help under Character Class Operators

"These can be used as an alternative way of representing classes of characters. For example, [a-z] is equivalent to [[:lower:]] and [a-z0-9] is equivalent to [[:lower:][:digit:]]. (Note the extra pairs of brackets.)"

Thus, after checking Regular Expression on your search, \w would be translated as [[:word:]]

If you are using TP's regex, you will most likely want to make it use Posix syntax so Configure, Preferences, on the Editor tab, check "Use POSIX regular expression syntax"
I choose to fight with a sack of angry cats.
anandm
Posts: 3
Joined: Wed Jul 02, 2008 8:08 pm

Post by anandm »

Thanks guys. My intent is to use my new knowledge in php eventually. Was using Textpad as a learning tool. The tutorial recommended to download editpad but I already had Textpad, so I thought I'd go with that.

I Just opened up a large text file and try various search strings to see how it behaved.
I do have the POSIX option on, something I discovered after I started to play with it.

And as you say [:blah:] does work like the \d and \w but is still a darned sight longer to type!
Post Reply