ovedpo15 has asked for the wisdom of the Perl Monks concerning the following question:
Hey guys, I'm trying to think of a basic regex which checks if a string is a substring of another string but they are not equal.
Example:
So the regex should return true for `$str2 =~ $str1` because $str2 is substring of $str1, but it should return false for `$str2 =~ $str3` because they are the same. Which regex should I use?
Example:
my $str1 = "helloworld"; my $str2 = "hello"; my $str3 = "hello";
So the regex should return true for `$str2 =~ $str1` because $str2 is substring of $str1, but it should return false for `$str2 =~ $str3` because they are the same. Which regex should I use?
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: regex and substrings
by Corion (Patriarch) on Jul 23, 2018 at 14:36 UTC | |
Re: regex and substrings
by jeffenstein (Hermit) on Jul 23, 2018 at 15:57 UTC | |
Re: regex and substrings
by AnomalousMonk (Archbishop) on Jul 24, 2018 at 15:51 UTC | |
A reply falls below the community's threshold of quality. You may see it by logging in. |
Back to
Seekers of Perl Wisdom