Given such Regex code:
Matcher m = Pattern.compile("c:.*?(|t:){1}.*?").matcher(string);
I only want to match something like c:somesubstring|t:somesubstring. However it also matches some thing like this:
c:somesubstring
and
c:somesubstring|a:somesubtring
How could this come? I use (|t:){1} to guarantee that the pattern |t: occurs and occurs only once. Will be helpful to tell me what's wrong with my regex and give me a regex to match only c:somesubstring|t:somesubstring
{1}does not guarantee that the preceding item does not appear more than once.