http://www.perlmonks.org?node_id=977138


in reply to regex search

Given that AnomalousMonk's response above doesn't answer your question, I think I get you now. What you're trying to achieve, actually, is this: you have a situation, in which you have these set of strings:

my $superstring = "123abc.def.ghi"; my $substring = "abc.def.ghi"; my $prefix = "123";

And what you want to do is to see whether $substring appears in $superstring, but only if it's preceded by $prefix?

Like this?

#### (pfff where is my head at. This won't work of course) $superstrin +g =~ m/$B$A/ $superstring =~ m/$prefix$superstring/;

If that's not it, then you'll have to explain what you mean with 'prefix' in this context.

Edit:Caught a stupid brainfail in the regex code. Fixed.