-2

I would like ask if is it possible to represent "?" quantifier using only union (+) and closure(*) quantifiers.

For example, "a+" can also represented as "a(a*)". How can you represent "a?" with only "*"s and "+"s?

Cœur
  • 37,241
  • 25
  • 195
  • 267
  • You could use the {0,1} which means match at least 0 occurences of previous char or at most 1 – FrenchMajesty Mar 11 '17 at 13:49
  • It's not possible with just `+` and `*`. You'll need alternation (`(a|)`) or capture groups and lookarounds (`(a(?!\2)())*`) or maybe some other tools. – Aran-Fey Mar 11 '17 at 13:56
  • Thanks for the reply. I raised up this question because I'm stuck in one of the questions of our mock exam in automata. We're only allowed to use union(+), closure(*), and concatenation expressions to describe every language. – Pat Atienza Mar 11 '17 at 14:04
  • @Rawing sounds like an answer to me, you should post it – Thomas Ayoub Mar 11 '17 at 17:26

1 Answers1

-1

a? can be represented as a + ε and, as mentioned, a+ can be represented as aa*.

Nathan Tuggy
  • 2,237
  • 27
  • 30
  • 38