Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Multirious |
func why_is_this_not_working():
var r := RegEx.new()
r.compile("`(?<=var).*?one.*?(?=var|$)`s")
var result = r.search("var one = 1 setget set_one, get_one")
Why is regex not working?
Tested on regex testing website and I’m supposed to get " one = 1 setget set_one, get_one"
What I’m working on:
Making my own doc generator
I’m trying to make a simple lexer (I think it’s a lexer) that’s getting a variable default value from a script (because the Script.get_property_default_value()
is not working. I’m also trying to make one for function, because default arg from methods list doesn’t return anything either).
If anyone got any better idea then feels free to suggest.
I assume you’ll need to do some additional escaping for GDScript
as mentioned in the docs. If that doesn’t help, post some sample strings you’re targeting and indicate exactly what you expect the regex
to extract from them…
jgodfrey | 2022-02-09 18:19
Yeah one thing I was thinking is that they are trying to use a Regular Expression for a different programming language in GDScript.
SF123 | 2022-02-09 19:24
Using current pattern for a regex testing website with the exact same string. I’m expecting " one = 1 setget set_one, get_one"
for this string. And for its main purpose is get any thing after var
with then variable name one
(which will be replace by %s
later) is found until next token (var
, func
etc.)
Multirious | 2022-02-10 11:33
I don’t really know very much about Regular Expressions (GDScript or otherwise) or I would help, sorry.
SF123 | 2022-02-10 21:47