I want to make sure that a text input field includes somewhere in the string {name}
literally, before submitting the form. For example it should match 123{name}456
I try the regex pattern {name}+
in regex101.com and other similar testers and it works as expected.
However, I learned that I should escape the brackets and after a lot of struggle I found how to match exactly {name} - with pattern = "\\{name\\}"
But when I try to make it match when there are other characters around, it just doesn't work. I tried "\\{name\\}+"
and "(\\{name\\})+"
and don't get what's wrong.
Please help, it's been an hour already...
Aucun commentaire:
Enregistrer un commentaire