Back to LanguageTool Homepage - Privacy - Imprint

Regex to match Any Number of Words


#1

Hi,

I am trying to create a regex that matches any number of words.

For example, (One) and (One Two) should both be found by the rule.

Currently, I have…

token: (
token: [\w\s]+
token: )

This successfully matches (One), but not (One Two),

Any suggestions?


(Daniel Naber) #2

You can use the max attribute to match more than 1 token. And if you use just <token/> it means “match any token”. So <token max="2"/> should work for one or two words (haven’t tested it now).