I'm very confused as to if a+ and a⁺ mean the same thing or are completely different.

  • 5
    $\begingroup$ It should be noted that, when you're dealing with practical implementations of regular expression syntax, the ^ symbol often means "the beginning of the string," and is therefore unavailable for notating superscripts. $\endgroup$
    – Kevin
    Nov 9 '21 at 18:01
  • 3
    $\begingroup$ @Kevin Indeed: I’ve submitted an edit suggestion changing ^+ to here to avoid that. $\endgroup$
    – KRyan
    Nov 9 '21 at 18:37
  • 2
    $\begingroup$ This is kind of like asking whether a || b and a or b are the same thing in the context of programming. The main difference is that different languages or authors use different ones (e.g. || in C++ and or in Python), and there may be small or big differences in how each language defines each of those things. $\endgroup$
    – NotThatGuy
    Nov 10 '21 at 0:42
  • $\begingroup$ @NotThatGuy Although not used commonly, you can also use or in C++ $\endgroup$
    – Tyilo
    Nov 11 '21 at 8:50

Usually that is a matter of taste. If I am nathematically motivated then I write $a^*$ like some single argument postfix operations in mathematics. If I keep close to applications, I would type $a*$ because typing superscripts in input for programs seems silly.

Same for $a^+$.

Be aware that in the context of regular expressions plus $+$ might have another meaning. It might be the same as "choice" or "union". Thus people can write $a+b$, $a\cup b$, or $a\mid b$ depending on their choice for that binary operator.

  • 2
    $\begingroup$ I would write $a^{+}b$ or a+b, but not $a+b$ or a⁺b. $\endgroup$
    – Bergi
    Nov 9 '21 at 21:05

a* means that "a" must occur zero or more times.
a+ means that "a" most occur one or more times.

In other words, a* allows an empty string, while a+ doesn't (unless a itself allows an empty string).

To write it: If your editor allows it easily, $a^*$ and $a^+$ are preferable, because they are correct. On this site: Dollar, a, caret, star, dollar for $a^*$. Exponent in curly braces like { 15 } if it is more than a single character, like $a^{15}$ and not $a^15$.

PS. Oh well. I read your question as a+ vs a*. Maybe $a^+$ is not such a good idea. Or I need new glasses :-(


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.