Please enable / Bitte aktiviere JavaScript!
Veuillez activer / Por favor activa el Javascript![ ? ]
As in lua to specify the number of characters in a regular expression? - bug-code.com Q&A

As in lua to specify the number of characters in a regular expression?

0 like 0 dislike
9 views
local string = "qw.erty" return string:match("([a-z]{2})%.")

Returns nil
In the manual anything about that word.
asked by | 9 views

1 Answer

0 like 0 dislike
For a start, it is better not to use the word string for the name variable, since this is a library for working with strings. You block access to it.

In Lua there is no full regular expressions, because Lua was conceived as the most easy language. Instead, a so-called "pattern match". So {2} is not working. Just in most cases enough modifiers + - * ?

In your case will fit:
local str = "qw.erty" return str:match("([a-z][a-z])%.")

Or even:
local str = "qw.erty" return str:match("(%l%l)%.")
answered by
Welcome to Bug-code Q&A, where you can ask questions and receive answers from other members of the community.

24.8k questions

46.2k answers

0 comments

12.7k users

24,788 questions
46,220 answers
0 comments
12,715 users