View Full Version : Character Classes in AMS 5?
Intrigued
10-10-2004, 05:21 PM
How can a user duplicate Character Classes in AMS 5 like those used in PHP 5?
I looked at the following page to try and find the equivalent in AMS 5:
http://www.lua.org/pil/20.2.html (seeing how LUA is Embedded into AMS 5)
Here is a very simple example of what I want to do:
num = 5;
if num == "1 or 2 or 3 or 4 or 5 or 6 or 7 or 8 or 9 or 0" then -- I want something more like [0-9] to minimize the code
Dialog.Message("", "Found a match!");
else
Dialog.Message("", "Sorry, no match");
end
I thought I had seen the solution before in the forums here... but alas... it seems that post has gone to the big code grave in the sky.
Any ideas?
Thanks in advance,
Intrigued
10-10-2004, 05:48 PM
I checked one page before the link I posted above and found this at the top of the page. I hope that does not mean what I think it means (no shorter way to accomplish such in LUA thus in AMS 5).
Here's the paragraph that is close to the top of the page:
Unlike several other scripting languages, Lua does not use POSIX regular expressions (regexp) for pattern matching. The main reason for this is size: A typical implementation of POSIX regexp takes more than 4,000 lines of code. This is bigger than all Lua standard libraries together. In comparison, the implementation of pattern matching in Lua has less than 500 lines. Of course, the pattern matching in Lua cannot do all that a full POSIX implementation does. Nevertheless, pattern matching in Lua is a powerful tool and includes some features that are difficult to match with standard POSIX implementations.
if String.TrimLeft(n,"0123456789") == "" then
--the variable n was numeric 0-9
end
But that would be true for any string that contained any combination of the above characters.
Intrigued
10-10-2004, 06:19 PM
So, my understanding of Character Classes must be accurate with regards to this endeavor it seems? It would be nice to have access to the (preferred) method I code-commented about in my prior post;however, Worm, thanks for your help nontheless. It will come in handy!
Sincerely,
Intrigued
11-07-2005, 07:59 PM
Update:
Solution found and an example created!
http://www.indigorose.com/forums/showthread.php?p=67846#post67846
It's more aptly called, I found, Character Range(s). That link above goes to a post where I have also created a little example. Forum TJ_Tigger gets the credit on finding this gem a ways back. I just wanted to add a note to this post incase I or anyone else comes upon it again.
:yes
Powered by vBulletin™ Version 4.0.6 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.