J
John Butler
Hi,
I have a regular expression
/\b2003|\2004|\2005|\2006|\2007|\2008|\2009\b/
and i want to check if various years are present.
"2003" =~ /\b2003|\2004|\2005|\2006|\2007|\2008|\2009\b/
returns 0 as expected
"2010" =~ /\b2003|\2004|\2005|\2006|\2007|\2008|\2009\b/
returns nil as expected
But i want only exact matches so when i search for "2003 - 2008" i want
nil returned as there is no exact match for that particular string. I
thought the \b would give me this but it doesnt.
"2003 - 2008" =~ /\b2003|\2004|\2005|\2006|\2007|\2008|\2009\b/
returns 0 i want nil returned.
Anyone help?
Jb
I have a regular expression
/\b2003|\2004|\2005|\2006|\2007|\2008|\2009\b/
and i want to check if various years are present.
"2003" =~ /\b2003|\2004|\2005|\2006|\2007|\2008|\2009\b/
returns 0 as expected
"2010" =~ /\b2003|\2004|\2005|\2006|\2007|\2008|\2009\b/
returns nil as expected
But i want only exact matches so when i search for "2003 - 2008" i want
nil returned as there is no exact match for that particular string. I
thought the \b would give me this but it doesnt.
"2003 - 2008" =~ /\b2003|\2004|\2005|\2006|\2007|\2008|\2009\b/
returns 0 i want nil returned.
Anyone help?
Jb