I'm trying to compare following strings with regex:
@[xyz="1","2"'"4"] ------- valid
@[xyz] ------------- valid
@[xyz="a5","4r"'"8dsa"] -- valid
@[xyz="asd"] -- invalid
@[xyz"asd"] --- invalid
@[xyz="8s"'"4"] - invalid
The valid pattern should be:
@[xyzthen=sign then some chars then,then some chars then'then some chars and finally]. This means if there is characters afterxyzthen they must be in format="XXX","XXX"'"XXX".- Or only
@[xyz]. No character afterxyz.
I have tried following regex, but it did not worked:
String regex = "@[xyz=\"[a-zA-z][0-9]\",\"[a-zA-z][0-9]\"'\"[a-zA-z][0-9]\"]";
Here the quotations (in part after xyz) are optional and number of characters between quotes are also not fixed and there could also be some characters before and after this pattern like asdadad @[xyz] adadad.