develooper Front page | perl.golf | Postings from June 2007

RE: regexp quickie

Thread Previous | Thread Next
From:
Roy.Johnson
Date:
June 27, 2007 12:49
Subject:
RE: regexp quickie
Message ID:
A3B4E948E728054CAC7A6D9C55EAB6A301F713C7@houic-s-348.americas.shell.com
> If you want $2 to only ever be the first letter at or after the target
> location, you can just tweak the second half of the regex:
> 
> /^(?=.{0,$r}([^_]))?(?:.{$r}.*?([^_]))?/

Save a stroke:
  /^(?=.{0,$r}([^_]))?(?:.{$r,}?([^_]))?/

Roy


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About