[thelist] regexp replace?

Benjamin kalos at carolina.rr.com
Thu Jun 20 06:50:00 CDT 2002


Using perl you could would do something like the following:

my $ssn = "111-22-3333";
$ssn =~ s/-//g;

The s/ is a substitution operation that replaces all instances of the dash
with nothing (thereby removing them) and the 'g' at the end tells the regex
to perform the substitution throughout the variable.

In the example above $ssn ends up set to "111223333"

Hope this helps.

-benjamin




More information about the thelist mailing list