perl tricky pattern matching

Discussion in 'Programming' started by ktsirig, May 13, 2006.

  1. #1
    Hi all!
    Suppose you have the following string of letters :

    $string ='LPSTEOPRTRYERTRETR';
    and you want to search for the following pattern inside the string:
    $pattern= LP[SKTAQEHLDN][TA][GN][EDASTV] =>5/6
    By saying 5/6, I mean that you can have one mismatch but still it must return success.
    If you check the string above, it has L, P, S, T and then E. There is no G in the pattern, but I am ok with it...
    So, my question is how can you set a threshold in pattern matching above which you will return success...
     
    ktsirig, May 13, 2006 IP
  2. MrSupplier

    MrSupplier Peon

    Messages:
    141
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    pattern: LP[SKTAQEHLDN][TA][GN]?[EDASTV]
    test:
    LPSTE - ok
    LPSTGE - ok
    LPSTNE - ok
    LPSTRE - no match

    good luck
     
    MrSupplier, May 15, 2006 IP