Answer the question
In order to leave comments, you need to log in
How to take into account the optional substring?
Hello)
In the line with keys t, h and w the key h is optional, for example, in the 2nd line there is no key h:
t:foo;h:foo;w:foo;
t:foo;w:foo;
I don’t understand how to make h optional in RegExp-e, the ? symbol is responsible for optionality in regular expressions. but I don’t understand where and how to put it so that these 2 lines of the regex correctly validate.
The Internet did not help surprisingly (I
only managed to write a regular expression to validate strings without the optional parameter
t:(.*);w:(.*);
Thanks for the help;)
Answer the question
In order to leave comments, you need to log in
Isn't that easier?
https://regex101.com/r/YF7z7I/2
For the key, you can set the range from the Latin alphabet, and the value with possible characters. You can add a case-insensitive flag.
Great idea!
Thank you.
I also unsuccessfully tried to do something similar)
Upd: I came with a change request that all lines that are parsed by a regular expression will be framed
by {{}}, like {{t:foo;w:foo;}}
Somehow it is very difficult in regular expressions such a seemingly simple change apply(
Thought I had to write like this \{\{(([thw]):([a-z09]+);)+\}\}
But this regular expression does not work as expected)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question