Title: RE: Simple regex question
$event = "Yet another @ test & string \$.?!" ;
$event =~ s/[^A-Z!\.,'"?()\s]//ig;
 
Produces:
 
event: Yet another  test  string .?!
-----Original Message-----
From: Ebel, Horst [mailto:[EMAIL PROTECTED]]
Sent: Thursday, November 09, 2000 7:44 AM
To: '[EMAIL PROTECTED]'; 'Goddard, Jeremy'
Subject: RE: Simple regex question

In this case, something like this will do:
 
    $event = "Yet another @ test & string \$.?!" ;
 
    $event =~ s/[^\w^\s^.^,^;^!^?]//g ;
    print $event ;
 
which will print
    Yet another  test  string .?!
 
 
Anyway I have to admit, it looks a bit uninspired to me ...
 
 
bye, horst
 
-----Original Message-----
From: Goddard, Jeremy [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, November 08, 2000 8:43 PM
To: 'Ebel, Horst'
Subject: RE: Simple regex question

Yes, But I need to preserve whitespace and other puncuation.

-----Original Message-----
From: Ebel, Horst [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, November 08, 2000 2:39 PM
To: '[EMAIL PROTECTED]'; 'Matt Grimaldi';
'[EMAIL PROTECTED]'
Subject: RE: Simple regex question


Yet Another Way To Do It:

        $event = "Yet another @ test & string \$.?!" ;

        $event =~ s/[\W]//g ;
        print $event ;

this will print:

        Yetanotherteststring

still I'm not sure whether this is, what you want ...

bye, Horst

-----Original Message-----
From: Matt Grimaldi [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, November 08, 2000 8:27 PM
To: 'Goddard, Jeremy'; Active Perl (E-mail)
Subject: RE: Simple regex question


You could try this:
 
$event =~ s/[^\w]//g;
 
which will erase all non-word characters,
 
\w matches alphanumeric characters and the underscore (_).
 
 
-- Matt Grimaldi
 
 
 

-----Original Message-----
From: Goddard, Jeremy [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, November 08, 2000 11:17 AM
To: Active Perl (E-mail)
Subject: Simple regex question



Hi There,

I need to filter out all non-alpanumbric, whitespace or punctuation
charators from a string. How could I do this?

i.e.

$event =~ s/[A-Z]//goi;

_______________________________________________
ActivePerl mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/activeperl
_______________________________________________
ActivePerl mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/activeperl

Reply via email to