Regular expressions: Examples

Test variable for string if ($data =~/<!-- Content -->/){$x++;}
This removes various items based on letter combinations in a pdf title if ($item !~ /^d|de\.pdf$|de(..)\.pdf$/i){
Remove all HTML $html =~ s/<[^>]+>//g;
Force all letters to lowercase $html =~ tr/A-Z/a-z/;
Count the letters in a word @chars = split //,$word;
Count the words in a sentance @words = split /\s+/, $line;
Removes spaces and non-alpha $line =~ s/\W//g;
Strip or clean html code in a regular expression. Taken from a newsgroup $context =~ s/<(?:[^>'"]*|(['"]).*?\1)*>//gs;



[Our portfolio] [A history of Computers and Networks]
[Perl help] [ABAP help] [MySQL help]
[TCP/IP troubleshooting] [HTML help] [Feedback] [Humor]
Advertise on Golden Ink's Georgia Network

In Association with