0 votes

I have this regular expression:
enter image description here

I want it to extract all ABs from the string but it gives this:
enter image description here

How do I get it to work? Will regular expressions do the trick in this case at all?
Most likely I just fail to understand the concept of regular expressions but I've tried several patterns and none of them have worked so far.

in Engine by (195 points)

1 Answer

+1 vote
Best answer

find() stop at the first match and returns the start index:

var i = 0

while r.find("ab aa bb, ab, ab", i) >= 0:

    i = r.get_capture_start(1) + r.get_capture(1).length()  
    prints(r.get_capture(1),  r.get_capture_start(1))


#ab 0
#ab 10
#ab 14
by (120 points)
selected by
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.