I am trying to build a regular expression that has the following rules:
Legitimate cases would be:
If this needs more clarification just let me know, it's kind of hard to explain it.
I currently have this for my regular expression:
(\w+\.)*(\*|\w+)\=\w+
Which correctly validates the given examples, however it matches ".*=INFO" which should be invalid. Anyone know how I can get it to not match this string?
^(\*|\w+(\.\w+)*(\.\*)?)\=\w+$
This handles separately cases which start with an asterisk and those which start with a character, since I wasn't able to combine them.
^ begin
(
\* asterisk
| or
\w+ first word
(\.\w+)* optionally more words, separated by dot
(\.\*)? optional dot + asterisk
)
\= equals
\w+
$ end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With