![]() ![]() Character classĪs mentioned above, any upper-case version of those classes represents the complement of the class. For instance, the character sequence %a matches any letter, while its upper-case version represents all non-letters characters, all characters classes (a character sequence that, as a pattern, can match a set of items) are listed below. ![]() Both can be very similar, but Lua pattern matching is more limited and has a different syntax. Instead of using regex, the Lua string library has a special set of characters used in syntax matches. Throughout some examples, the notation ():function is used, which is equivalent to string.function(, ) because all strings have a metatable with the _index field set to the string table. ? match exactly 0 or 1 occurrence of previous character class lazy match 0 or more occurrences of previous character class + greedy match 1 or more occurrences of previous character class * greedy match 0 or more occurrences of previous character class represents the class which is the union of all characters in set. %g represents all printable characters except space String.gsub(str, pattern, repl ) - Replaces substrings (up to a max of n times) String.gmatch(str, pattern) - Returns a function that iterates through all matches in str String.match(str, pattern ) - Matches a pattern once (starting at index) String.find(str, pattern ]) - Returns start and end index of match in str ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |