merlyn's on-target comment aside, I'd normally do that by assigning the repeated pattern to a variable and interpolating that into the regex pattern.
# original: my $pat = "\d\s+foo"; # fixed: my $pat = "\\d\\s+foo"; my $regex = qr/$pat[^\r\n]*$pat/;
Not sure about PCRE, but whatever programming language you use, I suspect you can construct a string using variables similarly to build up to your pattern.
Update: Doh! Thanks, ikegami. I was trying to show the subpattern with strings for the cross-language analogy and slipped up.
-xdg
Code written by xdg and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.
In reply to Re: PCRE: Repeating Subpattens After Intervening Characters
by xdg
in thread PCRE: Repeating Subpattens After Intervening Characters
by schnarff
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |