cortezaproject / corteza

Low-code platform
https://cortezaproject.org
Apache License 2.0
1.62k stars 371 forks source link

match() function needs double backslash in the regex #1746

Open martkaczmarek opened 7 months ago

martkaczmarek commented 7 months ago

Is there an existing issue for this?

Version of Corteza

2023.9.4

Current Behavior

When using match() function in field validation, the regex definition containing backslashes must have these backslashed doubled to work. For example, a single regex that should return true on digits: ^\d+$ throws an error: image if I define the digits in another way, it works fine: ^[0-9]+$ Adding a second backslash to the original regex seems to fix it: ^\\d+$

Expected Behavior

match() function should accept raw regex expression, without the need to double-escape special characters.

Steps To Reproduce

  1. Create a text field
  2. Add the following validation step: match(value, "^\d+$")

Environment and versions

No response

Anything else?

No response

lennyhorstink2 commented 6 months ago

Someone else has this regex:

match(value,"\b([A-ZÀ-ÿ][-,a-z. '_]+[ ()]*)+")

https://regexr.com/7ucc2

I tried to add a double backslash, but to no avail. match(value, "^\d+$") works, but match(value,"\b([A-ZÀ-ÿ][-,a-z. '_]+[ ()]*)+") not.

Maybe there are more characters that are problematic?

github-actions[bot] commented 4 months ago

Stale issue message