How can I make some part of a regular expression optional? For example:
\ d * [\\ s \\ w *?] ... where expression inside the bracket is optional.
I do not think you want enough regular expressions. [\ S \ w *?] Says, "is a letter that is a place, matches a word, a star or a question mark". I think what you want ultimately (\ s \ w) *? Who says, "Match 0 or more places after the word and do not be greedy about it.
Though you are looking for (\ s | \) *, who says "Do not be the word or a place 0 or more often and greedy about it. "
Comments
Post a Comment