[Kc] Regexp help

Frank Wiles frank at wiles.org
Tue Aug 26 16:00:58 CDT 2003


On Tue, 26 Aug 2003 15:34:51 -0500
"SK-47" <linux at kisuu.com> wrote:

> I am having difficulties crafting 2 regexps.
> 1. Accept year between 1900 and 2100 OR a string "blah"
> 2. Accept 1 to 12 digits in a supplied number
> 
> Any help will be appreciated.

  The first one you don't need a regex you need something like this: 

  if( $year eq 'blah' or ( 1900 <= $year <= 2100 ) ) { }

  The second one can be accomplished with something like: 

  if( $number =~ /^\d{1,12}$/ ) {}

  Hope this helps. 

 ---------------------------------
   Frank Wiles <frank at wiles.org>
   http://frank.wiles.org
 ---------------------------------




More information about the kc mailing list