I need a regular expression to match only the first two words (they can contain letters, numbers, commas and other punctuation marks, but not white spaces, tabs or new lines) per line. My solution is ([^\s]+\s+){2} , but if it matches something like: "123 word '* in" 123 word, hello' *, it does not work with a two-word string and without spaces after.
What is the correct regular expression for this task?
source share