Search your unanswered perl queries
Google
Showing posts with label Perl Regular Expressions. Show all posts
Showing posts with label Perl Regular Expressions. Show all posts

Wednesday, December 3, 2008

Cleaning A Perl File With REGEXP

Following are the regular expressions which can be used to clean your file of unwanted material

1) Replace all the spaces with nothing.

s/\s//g;

2) Skip the lines with comments.

next if (m/^\#/);

3) skip blank lines

next if (m/^$/);

4) Replace a line in the file which has commented data on a code line.

s/\#.*$//;

5) Replace a line in the file which has data after semicolon

s/\;.*$//;

Wednesday, November 28, 2007

Regular Expressions : email id

Almost everyone of us have sometime or other tried to write a regular expression for email ids and other stuff. \b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b

Here is a link to regular expression site which reports various aspects of regular expressions related to perl, shell and many others. It has a classic example of regex for email id.