in reply to How can I remove unwated parts of a string in a pattern match?

Got it!
I ran:
if($ig_string=~/.*\;(.*?$small_string.*?)\;/)
  • Comment on Re: How can I remove unwated parts of a string in a pattern match?
  • Download Code

Replies are listed 'Best First'.
Re^2: How can I remove unwated parts of a string in a pattern match?
by Laurent_R (Canon) on Dec 14, 2015 at 18:50 UTC
    Hi,

    although your regex most probably works fine, the initial part (.*) is useless if you can describe better what you want to match, and the semi-colons don't need to be escaped. You could consider something like this:

    if ($big_string =~ /;([\w ]+$small_string[\w ]+);/)