I am studying regular expressions, I have realized that perr[ao]
and perr(a|o)
are equivalent.
Here comes my question (which is surely bullshit), is there no difference in this regard? I mean, for less typing, could you use perr[ao]
? I guess doing this, short as it is, is neither semantic nor good practice.
What is your opinion?
I know that it is different to apply (a|o) to [ao] (for different cases).
The alternate pip operator will loop
|
through the text 2 times if the expression on the right is not true, which will slow it down a bit. While the literal text expression will[]
simply check if at least 1 character is present in the text.