in reply to repeating patterns

let me clarify, the dot in the string just stands for a bunch of stuff which changes

Replies are listed 'Best First'.
Re: Re: repeating patterns
by arturo (Vicar) on Mar 30, 2001 at 20:15 UTC

    OK, you have a string that has an unknown number of occurences of the pattern "a (something)foobara"; and you want to grab all of those instances. The tag in the middle can change; so the key is to use the fact that you can interpolate variables into a regex.

    #since delimiter may contain special regex characters, # make sure you escape them my $delim = quotemeta("DELIMITER"); my @matches = $string =~ /a${delim}foobar/g;

    Will, *I think*, do what you want. But this might not get you what you want when you're dealing with real data, so beware.

    Philosophy can be made out of anything. Or less -- Jerry A. Fodor