Home: Perl Programming Help: Regular Expressions:
Regex for non-word chars excluding - (minus) and =(equals)



radhikj
New User

Dec 14, 2009, 12:27 AM


Views: 4710
Regex for non-word chars excluding - (minus) and =(equals)

Hi,

I'm trying to frame a regular expression where I have to search for the non-word characters except - and =. Currently I have put all the meta chars and non-word chars other than - &= for my search. But I think there should be alternate and easy way to get it.

For .eg., I have to search for string like abc%de_f (this regex matching this should work for any patterns with non-word chars except - and =)

Any help on this would be highly appreciated.

Thanks,

Radhika


shawnhcorey
Enthusiast


Dec 14, 2009, 7:10 AM


Views: 4700
Re: [radhikj] Regex for non-word chars excluding - (minus) and =(equals)

Try:

Code
/[^-=[:alnum:]]/


__END__

I love Perl; it's the only language where you can bless your thingy.

Perl documentation is available at perldoc.perl.org. The list of standard modules and pragmatics is available in perlmodlib.

Get Markup Help. Please note the markup tag of "code".