in reply to Re^2: doubt in string matching.
in thread doubt in string matching.

Mandrake You are right, if the $find string is "CXYF". But my solution is based on the OP's logic. If the strings are "CDEF", "QRST" etc. it ll work perfectly. The OP has given,

i keep incrementing first(after finding C)

Prasad

Replies are listed 'Best First'.
Re^4: doubt in string matching.
by Mandrake (Chaplain) on Oct 17, 2006 at 06:47 UTC
    Sorry but unless you perform a check at each increment, this incrementing does not prove good. Your implementation just checks the first and last characters only. This will return success if
    $find = "CDED"; # or $find = "CDEH"; # or $find = "CDEJ"; #or even $find = "CDEC";
    Also if you check the pattern closely,
    BCDEFGHIJKLMNOPCDEFQRST
    you can find a CDEF in-between the P and Q. So incrementing the string from $first..$last should not be the approach here.
    I believe by "incrementing" what OP meant was incrementing the search string from first to last position. Thanks..

      Mandrake You are absolutely correct, but OP has not given enough samples of input and he has not given the exact requirement clearly, which I mentioned in my first reply itself and the samething was highlighted by ikegami and chargrill. So I assumed he might have inputs with incremented characters inbetween instead of random characters.

      ikegami has mentioned

      We can't help you if you can't even describe what you want accuratly

      chargrill has mentioned

      I don't know what you mean. Solid examples will speak volumes, show us what output you want to get.

      Prasad