![]() |
|
Just another Perl shrine | |
PerlMonks |
Re: Regex helpby strider corinth (Friar) |
on Nov 16, 2002 at 13:59 UTC ( #213395=note: print w/replies, xml ) | Need Help?? |
You've got it almost right, from what I can see. Your post looks a little strange (you'll notice your brackets are missing) because PerlMonks uses brackets to make linking easier in posts (anything in brackets links to the node named whatever's within the brackets). In the future, you'll probably want to put <code> tags around any code you post. From what I can see, your regexp looks like this: /^[A-Za-z0-9]/ There's only one small error- the ^ is outside of the brackets. A caret outside of brackets means 'match this regexp at the beginning of a string'. If you move it inside: /[^A-Za-z0-0]/ you should find that it does what you want it to. Incidentally, there are two shortcuts you might be interested in. You can use the escape sequence "\w" to mean "match all alphanumeric characters plus '_'", and "\W" to mean "match everything but \w". So if it's ok for you to add "_" to the class of characters that are ok to find, the whole thing can be shortened to /\W/. A good place to look for more information on this is the perlre man page. Happy Perling! -- Love justice; desire mercy.
In Section
Seekers of Perl Wisdom
|
|