I have a string of the format, {Key=value, Key=value.....}
for which I have to write a validator. The above key-value are separated by space {Key=value, Key=value, Key=value.....}
.
I am completely new to regex but referring to one of the answers in Stack overflow I have written:
Boolean check = Pattern.matches("(\\{+)?(\\w+)?=(\\w+)?,?","string to be validated");
But the solution is not working.
It is also possible that the expected string could either be empty()
or of the exact type <null>
?
Any help is appreciated.