I'm studying a Java code that uses the regular expression "( *|)"
. What does the pipe do in this expression?
So far I understood it works the same way as the expression for a group of optional spaces, i.e. "( *)
.
I'm studying a Java code that uses the regular expression "( *|)"
. What does the pipe do in this expression?
So far I understood it works the same way as the expression for a group of optional spaces, i.e. "( *)
.
Pipe ('|') simply means 'or'. At the one side we have regex for zero or more spaces, on the other side we have nothing - so it will match zero or more spaces or an empty string.