I would like to match either of the strings - abc
or abc*
or abc?
or abc{abc}
.The following .*?(\?|\*|\{.*?\})
regex matches all the above except abc
. Even .*?(\?|\*|\{.*?\})?
does not work.
Any help will be appreciated. (I am using java)
Check if the below pattern help?
Demo: https://regex101.com/r/XtEPSe/2
Pattern: .+?(\?|\*|\{.*?\}|$)|(?:^$)
Detail:
.*?
to .+?
. To match empty string added a alternate ^$
at the end. Plese remove it if it is not required.$
to match abc