Confusing about regular expressions.

51 Views Asked by At

I am new to regular expressions. Hence, it is a bit confusing to me. If I have a regular expression such that $(AAAA^{*}X)^{*}AAAA^{*}$, does $g=AAAAXAAAXAAAAXAAA$ can be one of the expressions? Also, which of the following is the correct way to express the regex?

  1. $(AAAA^{k}X)^{l}AAAA^{m}$ where we fixed value of $k$ first, then repeated the bracket $l$ times, in which I can never get the expression $g$. eg:$(AAAAAX)^{2}AAAAA=AAAAAXAAAAAXAAAAA$

    or

  2. $(AAAA^{*}X)(AAAA^{*}X)...(AAAA^{*}X)AAAA^{*}$ in which I can get the expression $g$ that I want. However, I am worried this is the wrong idea of regex.

Please help me to understand how to read the regex and express them to have the correct expressions.

Thank you.

1

There are 1 best solutions below

1
On BEST ANSWER

Yes, $AAAXAAAXAAAAXAAA$ satisfies $(AAAA^*X)^*AAAA^*$.

Your second option is correct. Elements of $L^*$ are concatenations of sequences of (potentially different) elements of $L$, so elements of $(AAAA^*X)^*$ are concatenations of sequences of (potentially different) words of the form $AAAA^*X$.