Forum Moderators: coopster & phranque

Message Too Old, No Replies

pattern matching Perl with conditions

         

ktsirig

10:45 am on May 13, 2006 (gmt 0)

10+ Year Member



Hi monks!
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...

perl_diver

7:03 pm on May 13, 2006 (gmt 0)

10+ Year Member



You have this question on another forum. I didn't understand it there and I don't understand it here. Maybe someone else can help you.

coopster

4:29 pm on May 15, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



What if you made that part of the pattern optional?

lexipixel

4:26 pm on May 16, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Maybe you need to match character by character and keep score... (ie- "two strikes and you're out", zero or one and you're in)...