Gossamer Forum
Home : General : Perl Programming :

Only process 1/2 digit numbers?

Quote Reply
Only process 1/2 digit numbers?
Hi. I'm trying to process a string like below;

Quote:
Mon 5 2003,
Tue 6 2003,
Wed 7 2003,
Thur 8 2003,
Fri 9 2003,
Sat 10 2003

I'm using this line of regex;

$calander =~ s/((\d\d)?|(\d)?)/<a href="$1">$1<\/a>/g;

Is there a way to modify this so it ONLY does the 1/2 digit numbers? i.e so it looks like; (i.e without the year being slip in 2, and changed to a link)

Quote:
Mon http://5th 2003,
Tue http://6th 2003,
Wed http://7th 2003,
Thur http://8th 2003,
Fri http://9th 2003,
Sat http://10th 2003



Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Only process 1/2 digit numbers? In reply to
Not sure what all that stuff with the \d's is....use:

\d{1,2}

or

\d\d?

...and verify it's the right digits by looking for spaces.

\s+(\d\d?)\s+