[ao] is the same as (a | o)? Regular expressions

1

I'm studying regular expressions, I've noticed that perr[ao] and perr(a|o) are equivalent.

Here comes my doubt (which surely is a bullshit), is there no difference in this regard? That is, by writing less, could I use perr[ao] ? I suppose that doing this, however short, is neither semantic nor good practice.

What do you think?

I already know that it is different to apply (a | o) to [ao] (for different cases).

    
asked by Saul 02.07.2018 в 22:08
source

1 answer

2

The alternate pipe operator | will scroll through the text 2 times if the expression on the right is not fulfilled, which will make it a little slower. While the literal text expression [] simply checks if at least 1 character is present in the text.

    
answered by 03.07.2018 / 14:49
source