On Fri, 2009-09-11 at 15:09 -0400, Alex wrote:
> I'd like to create a rule that matches a specific letter and up to 5
> spaces after it, repeated ten times. I'm thinking something like this:
> 
> /s\ {5}o\ {5}n\ {5}i\ {5}c\ {5}\ m\ {5}e\ {5}d\ {5}i\ {5}a/i

A space does not have any special meaning in REs. Don't escape it.

The quantifier {5} means *exactly* 5 occurrences. What you are after is
the {n,m} quantifier with an lower n and (optional) upper m bound. Thus,
to match at least one, and up to 5 occurrences: {1,5}


> I'm still learning regex's, so hopefully this isn't too far off. The
> opportunities for rules are coming faster than my ability to learn.

  http://perldoc.perl.org/perlre.html

The reference. In particular, also do have a look at the perlrequick
Introduction and perlretut Tutorial referenced early in the Description
section.


-- 
char *t="\10pse\0r\0dtu...@ghno\x4e\xc8\x79\xf4\xab\x51\x8a\x10\xf4\xf4\xc4";
main(){ char h,m=h=*t++,*x=t+2*h,c,i,l=*x,s=0; for (i=0;i<l;i++){ i%8? c<<=1:
(c=*++x); c&128 && (s+=h); if (!(h>>=1)||!t[s+h]){ putchar(t[s]);h=m;s=0; }}}

Reply via email to