Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | supaiku | |
Old Version | Published before Godot 3 was released. |
Hi,
the code editor is not so happy with my regex literal
E.g
myRegex.compile("/\d+/g") => Parser Error: Invalid escape sequence
Obviously I can’t escape the \ character here.
How can I make him swallow my regex?
(Godot 2.1 Beta)
What do you mean “Obviously I can’t escape the \ character here”? You actually need to escape, since this is no more than a regular string. Just use "/\\d+/g"
.
vnen | 2016-07-19 21:38
I tried it, but then the regex doesn’t work. regex.find(text)
then regex.get_captures() # => []
. But the text definitely contains numbers and it works for me here https://regex101.com/ That’s why I said obvious, because it seems to me to change the entire semantic.
supaiku | 2016-07-20 05:44