I have a regex that looks something like this:
a(|bc)
This expression matches strings "a" perfectly, but does not match "abc". What does the expression in parentheses mean?
Edit:
Using C # with the following code:
Match m = Regex.Match(TxtTest.Text, TxtRegex.Text);
if (m.Success)
RtfErgebnis.Text = m.Value;
else
RtfErgebnis.Text = "Gültig, aber kein Match!";
"TxTTest" contains the string to check (in this case, "abc"). "TxtRegex" contains the regular expression (in this case, "a (| bc)")
"RtfErgebnis" shows "Gültig, aber kein Match!" this means that the regular expression is valid, but the given test string does not match.
On a side note:
Expression
a(|bc)d
matches "ad" as well as "abcd". So why the previous expression does not match "abc"?
, . . , .
2:
"RtfErgebnis" "Gültig, aber kein Match!", , , .
, "a", .