Web Design and Development Forums

perl tricky pattern matching

This is a discussion on "perl tricky pattern matching" within the Perl, Python, Ruby and Others section. This forum, and the thread "perl tricky pattern matching are both part of the Program Your Website category.

Old May 13th, 2006, 10:45   #1 (permalink)
Up'n'Coming Member
 
Join Date: Sep 2005
Location: athens
Age: 25
Posts: 59
perl tricky pattern matching

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 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old May 14th, 2006, 02:33   #2 (permalink)
Reputable Member
 
Join Date: Jul 2005
Location: Melksham, Wilts, UK
Posts: 294
Re: perl tricky pattern matching

There is no concept of nearly matching with regular expressions, but you could match each part conditionally and see how many are missing:

Code: Select all
$string ='LPSTEOPRTRYERTRETR';
@mat = $string =~ /^(LP)?([SKTAQEHLDN])?([TA])?([GN])?([EDASTV])?/;
$count = grep(/^$/,@mat);
print ("$count missing element(s)\n");
-- Graham
__________________
Graham Ellis ...
Open Source trainer with Well House Consultants
grahame is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Tags
perl, tricky, pattern, matching

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Matching HTML And Storing josephman1988 Perl, Python, Ruby and Others 0 Feb 18th, 2008 13:25
dual random image genetator...tricky drappendix JavaScript Forum 15 Sep 6th, 2007 01:51
Opening a specific report by matching user input to report ame autoIT MSSQL & Access 2 Apr 26th, 2007 17:32
tricky floating problems for div alignment escaflowne11 CSS Forum 4 Dec 10th, 2006 08:03
Find next matching record? Tim356 PHP Forum 5 Sep 20th, 2006 21:02



Latest Updates

All Points SEO Security Advisory - CHECK YOUR SITE NOW!

Creative Coding :: February 2008

Webforumz is sponsored by: WESH UK Web Hosting
All times are GMT. The time now is 23:04.

Sleep Study Scoring :: Free Bet :: Website Templates :: Online Betting :: Bookmakers :: Funny Quotes :: Internet Recruitment Software :: Microsoft CRM Experts :: Online Casino :: Decorated Christmas Trees :: Midwife Forums :: Football Betting :: Ecommerce Software :: Web Hosting :: Football Stats :: Dry Cleaning Collection :: xtreme wales - extreme clothing :: Apuestas :: Sharepoint Consultants :: Website Optimisation :: Office Clearance London :: Sharepoint Experts :: Sports Betting :: Casino :: Website Templates :: Web Design Development India :: Online Gambling

Powered by: vBulletin Version 3.7, Copyright ©2000 - 2008, Jelsoft Enterprises Limited.
© 2003-2008 Webforumz.com : All Rights Reserved
Search Engine Friendly URLs by vBSEO 3.2.0 RC6


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59