[Pdx-pm] Regex

David E. Wheeler david at kineticode.com
Sat Feb 4 22:59:33 PST 2012


On Feb 4, 2012, at 10:54 PM, Russell Johnson wrote:

> Usage:524,944 of 1,000,000 messages
> 
> I need the two numbers. The old line was this:
> 
> Usage:524944/1000000 messages
> 
> Which I matched with the following code:
> 
> if ($info =~ m|Usage\:(\d+)/(\d+) messages|)
> 
> Further complicating matters is that the first number starts at 0, and counts up, so it won't always have a comma. I need to process the two numbers inside the if construct. 

if ($info =~ /Usage:([\d,]+)\s+of\s+(\d+)\s+messages/) 

HTH,

david


More information about the Pdx-pm-list mailing list