in reply to Re^2: search of a string in another string with 1 wildcard
in thread search of a string in another string with 1 wildcard

You need to loop through regexes. Or, maybe something like:
... push @regexes, $regex; } my $r = join '|', @regexes; $r = qr/($r)/; # compile the regex say "Regex is: $r"; # debug my $string_to_search = "djflsbcdefgkgjdslkgjabfoéabcdefg"; if ($string_to_search =~ $r) { say "Found it ($1) at position ", $-[0]; } # there is a useful magic variable @- (LAST_MATCH_START) # check perldoc for it
Output:
Regex is: (?^u:(.bcdef|a.cdef|ab.def|abc.ef|abcd.f|abcde.)) Found it (sbcdef) at position 4

Replies are listed 'Best First'.
Re^4: search of a string in another string with 1 wildcard
by carolw (Sexton) on Jul 10, 2014 at 14:03 UTC

    Works like a charm. Many thx