Skip to main content
added 10 characters in body
Source Link
sra
  • 24k
  • 8
  • 59
  • 89

Try rgx("(?:(\w+)\W+)+");rgx("(?:(\\w+)\\W+)+"); as your regex. (?:?: will start a non-marking group which is finished by the matching )+)+ which will match the words in the string 1 or more times (\w+)(\\w+) will match alpha, digits and underscores 1 or more times as a marked group, i.e. typical word like characters which are returned to you in result[i] \W+\\W+ will match one or more contiguous non-word characters, i.e. whitespace, |, - etc.

Try rgx("(?:(\w+)\W+)+"); as your regex. (?: will start a non-marking group which is finished by the matching )+ which will match the words in the string 1 or more times (\w+) will match alpha, digits and underscores 1 or more times as a marked group, i.e. typical word like characters which are returned to you in result[i] \W+ will match one or more contiguous non-word characters, i.e. whitespace, |, - etc.

Try rgx("(?:(\\w+)\\W+)+"); as your regex. (?: will start a non-marking group which is finished by the matching )+ which will match the words in the string 1 or more times (\\w+) will match alpha, digits and underscores 1 or more times as a marked group, i.e. typical word like characters which are returned to you in result[i] \\W+ will match one or more contiguous non-word characters, i.e. whitespace, |, - etc.

Source Link

Try rgx("(?:(\w+)\W+)+"); as your regex. (?: will start a non-marking group which is finished by the matching )+ which will match the words in the string 1 or more times (\w+) will match alpha, digits and underscores 1 or more times as a marked group, i.e. typical word like characters which are returned to you in result[i] \W+ will match one or more contiguous non-word characters, i.e. whitespace, |, - etc.