p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/)
-   BOOK Beginning Lua Programming ISBN: 978-0-470-06917-2 (http://p2p.wrox.com/book-beginning-lua-programming-isbn-978-0-470-06917-2-303/)
-   -   string comparison (http://p2p.wrox.com/book-beginning-lua-programming-isbn-978-0-470-06917-2/85272-string-comparison.html)

Antheor October 8th, 2011 08:23 AM

string comparison
 
I've tried to master your though very clear "using strings" chapter, but it's still a bit confused [:I]

I only wish to do the following with two strings :
subject = "abcdeabcde"
pattern= "cbaaaf"
comparison(subject,pattern)
and then get
- pattern letters found in subject, getting : 4 cbaa
- subject letters missing in pattern, getting : 6 debcde

My strings are lower letters only, I don't care about letters order in my results.
What I really wish to do is to go through the subjectstring and get the following answer for each letters : isinPattern or isnotinPattern. The problem is that I don't know how to tell, once a letter in pattern has been "used" for comparison", not to look at it again :
When I reach the first c (abCdeabcde) in the subject, I should get OK, but when I reach the second c (abcdeabCde), I should get Not in pattern (since there is only one c in my pattern)...
Hoping I'm clear [:)]


On the other hand you provide a cool strtoarray function. Maybe I should convert my string to table then try to compare them...


All times are GMT -4. The time now is 04:38 PM.

Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
2013 John Wiley & Sons, Inc.