dude01 has asked for the wisdom of the Perl Monks concerning the following question:

How would i match any non-digit except '-' or ' ' ? Thanks chris

Replies are listed 'Best First'.
(Ovid) Re: regex match
by Ovid (Cardinal) on May 09, 2001 at 23:00 UTC
    Assuming the final character you have is a space:
    my $string =~ /[^\d\- ]/;

    Of course, how you actually turn that into a useful regular expression will depend upon the structure of the data to be tested.

    For example, if you want to ensure that $string has no characters that you wish to exclude (and is not empty):

    if ( $string =~ /^[^\d\- ]+$/ ) { # do something here }

    Cheers,
    Ovid

    Join the Perlmonks Setiathome Group or just click on the the link and check out our stats.

      Actually the first example works fine since there is a possibility that the string is all blank. It works! Thanks,