in reply to Should I escape all chrs in a regex?

If you're (literally) searching for a string within another, you don't need to use regexp matching:
my $sub_str = "tftp>"; my $full_str = "# tftp> connect tftp.host.com 69"; my $i = index($full_str, $sub_str); # $i is 2

It's good to know when to use index and rindex.

Replies are listed 'Best First'.
Re^2: Should I escape all chrs in a regex?
by MikeKulls (Novice) on Sep 29, 2010 at 05:47 UTC
    Thanks repellent, I do often forget about using index although this was just a simplified example. I was assuming whatever I am searching for is complicated enough to need a regex.