rakugoteam / Rakugo-Dialogue-System

Inspired by Ren'Py, Rakugo is a project aiming to provide a way to make narrative-based games on Godot easily. Simplify your project, if it is a visual novel, point and click, RPG, interactive text game or many other styles and blends of styles.
https://rakugoteam.github.io
MIT License
220 stars 7 forks source link

Parser, Variable are also captured in String #99

Open theludovyc opened 2 years ago

theludovyc commented 2 years ago
VARIABLE = "((?<char_tag>{NAME})\\.)?(?<var_name>{NAME})"

In "Test character" return Test.

theludovyc commented 2 years ago

For now, I don't know how to detect match are in string with regex

Jeremi360 commented 2 years ago

For now, I don't know how to detect match are in string with regex

I'm not sure what you mean by this @theludovyc , can you elaborate on this topic ?

theludovyc commented 2 years ago

I don't know how to resolve this bug for now. I need to learn more about regex. If you or other already know how to solve it with regex, feel free to help :)

Jeremi360 commented 2 years ago

I want try to help you @theludovyc , but I'm not sure what you mean by , can you give example or something ?

For now, I don't know how to detect match are in string with regex

theludovyc commented 2 years ago

For JumpIf I use Expression class. To dectect used variables I use this regex VARIABLE = "((?<char_tag>{NAME})\\.)?(?<var_name>{NAME})" You can write something like that jump todo if test.name = "Test character" When I use VARIABLE on test.name = "Test character" it return 3 match, test.name, Test and character. First one is good but I don't want Test and character because they are in String. So I need to update my regex and check if match are not in String.

Jeremi360 commented 2 years ago

jump todo if test.name = "Test character" When I use VARIABLE on test.name = "Test character" it return 3 match, test.name, Test and character. First one is good but I don't want Test and character because it is in String. So I need to update my regex and check if match are not in String.

O I see you just want to catch string in regex. I went to Godot Dialogue Manger repo from which I borrow regex approuch, and there found this line: DialogueConstants.TOKEN_STRING: "^\".*?\"", - this regex should to it.

theludovyc commented 2 years ago

First one is good but I don't want Test and character because they are in String. O I see you just want to catch string in regex.

No, the opposite. I want to catch regex if they aren't in String.

Jeremi360 commented 2 years ago

I try a bit of experiment on regex.com and found this solution: regexr.com/6nke5 , but you still need to check in code if string don't starts from "