Reputation: 65
I've got a string where I need to aleays select just the second and third wodr in a string. Currently I can only select the first three words but I need to skip the first word. I currently have:
^(?:[^ ]*\ ){2}([^ ]*)
Any help wouild be aprreciated. Thanks!
Upvotes: 0
Views: 108
Reputation: 163217
You can capture the second and the third "word" as in 1 or more non whitespace characters:
^\S+ (\S+ \S+)
Or if supported with a lookbehind:
(?<=^\S+ )\S+ \S+
Upvotes: 1
Reputation: 609
I think this is the regex you're looking for:
(?<=\s)([^ ]*)
Link to example: https://regex101.com/r/wSdzLe/1
Upvotes: 0