in reply to Re: regex finding longest string containing n of $c
in thread regex finding shortest string containing n of $c

That will work (with a little modification for the revamped question too). Hadn't thought of just repeating the search letter with * between- simple now that I see it. Thanks!
  • Comment on Re^2: regex finding longest string containing n of $c

Replies are listed 'Best First'.
Re^3: regex finding longest string containing n of $c
by GrandFather (Saint) on Sep 01, 2005 at 04:18 UTC

    A regex is not going to do it for you because it will find the first match regardless of the length of the match. If you need to find the shortest (or longest) match then you need to find all the matches and select the best. A regex on it's own generally doesn't do that.


    Perl is Huffman encoded by design.
      Since I want to start at the begining of $foo, and can use *? between $c, Mark's updated solution works as desired.