in reply to Re: Contents b/w two given text
in thread Contents b/w two given text

Unless you are certain that $t1 and $t2 have no special regular expression characters, like [ ] . * ? + ( ) \ ^ $ ? and so on, you should clip them with \Q \E.
#!/usr/local/bin/perl -w use strict; my $string = "blah text1 you mean more like this? text2 blah"; my $t1 = 't(e*x+t)1'; my $t2 = 't[ex]*t?2'; my $match = qr/\Q$t1\E(.*?)\Q$t2/; print "no match\n" unless $string =~ m/$match/s;

--
[ e d @ h a l l e y . c c ]