[sf-perl] regular expression ?

Michael Friedman frimicc at gmail.com
Mon Sep 26 12:19:41 PDT 2011


You probably want to use \d, the special metacharacter that matches digits.

Something like this would probably work:

if ($text =~ m/Thank you for order:\s+(\d+)/) {
	$order_num = $1;
}

See also the perlre manpage for the list of all the other metacharacters:
http://perldoc.perl.org/perlre.html#Regular-Expressions

-- Mike
_________________
Michael Friedman
frimicc at gmail.com



On Sep 26, 2011, at 12:14 PM, Richard Reina wrote:

> I am trying to match a string "Thank you for order: 55555";
> 
> The order number will always change but I want the match to be true if the
> string has "Thank you for order:" followed by a number and extract the
> number.
> 
> Any help would be greatly appreciated.
> _______________________________________________
> SanFrancisco-pm mailing list
> SanFrancisco-pm at pm.org
> http://mail.pm.org/mailman/listinfo/sanfrancisco-pm



More information about the SanFrancisco-pm mailing list