regex - regular expression evaluation in string matching -
i reading regular expression in algorithms robert sedgwick book.
here regular expression mention below
a* | (a*ba*ba*)*
here author mentioned matches are: aaa, bbaabb, , babaaa. not match above regular expression aba bbb babbaaa.
my question how bbaabb matching , same way how babaaa matching. kindly explain.
in general looking how evaluate | , * operators in regular expressions. in below example how can b alone in set if have a+ since says must have atleast 1 a.
(a+b)* = (λ, a, b, aa, ab, ba, bb, aaa, ...)
there 1 difference between *
, +
. character after put *
can have no repetition. in +
case, can have minimum 1 repetition. in a* | (a*ba*ba*)*
, bbaabb
valid following reasons , according (a*ba*ba*)*
pattern
- no
a
@ starta*
- 1 b
ba*
, noa
- 1 b
ba*
, 2 a *
@ end of(a*ba*ba*)*
shows pattern can repeat. second repetitionbb
valid
these points bbaabb
valid.
Comments
Post a Comment