Next | Regular Expression Mastery | 66 |
/(\w|::)*/
Perhaps a more general solution involves the new (?>...) operator:
/((?>\w+)|::)*/
State is saved as usual inside the fence
But this state is discarded when the node pointer exits the fence
State can backtrack past the fenced area
But not into the fenced area
\w+ might match many different strings
(?>\w+) says that only the first choice can be correct
If the first choice doesn't work, don't try any other choice
Next | Copyright © 2002 M. J. Dominus |