regular expression (made more clearer)
From: Mandar Rahurkar (rahurkar_at_uiuc.edu)
Date: 05/29/04
- Next message: Beau E. Cox: "Re: regular expression"
- Previous message: James Edward Gray II: "Re: regular expression"
- Next in thread: John W. Krahn: "Re: regular expression (made more clearer)"
- Reply: John W. Krahn: "Re: regular expression (made more clearer)"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Fri, 28 May 2004 20:52:43 -0500 To: James Edward Gray II <james@grayproductions.net>
Hi,
I am trying to remove from file :
1. all characters but any alphabet and numbers (i.e., file shd not contain anything
but "alphabets and numbers" that means NO punctuation etc...
2. all trailing spaces should be made to one space.
following code doesnt seem to work for objective [1] mentioned above. Can anyone please point whats wrong with the
second line and what changes should I make ?
Thanks,
Mandar
---
open(fp,$file) or die "Cant open $file :$!\n";
@cont=<fp>;
for(@cont) {
tr/A-Z/a-z/; # converts all uppercase to lowercase
s/^[a-z0-9]+/ /; # substitute all non alphabets and numbers by space
s/\s+/ /g; # removes trailing spaces
}
---
-------------------
Mandar Rahurkar
ECE, UIUC
-------------------
- Next message: Beau E. Cox: "Re: regular expression"
- Previous message: James Edward Gray II: "Re: regular expression"
- Next in thread: John W. Krahn: "Re: regular expression (made more clearer)"
- Reply: John W. Krahn: "Re: regular expression (made more clearer)"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|