Reputation: 1184
I have the following string
var str = "Format-ABC-D Type-O"
I would like to get "ABC-D" out of this string. so fat I have
str.(/Format-(\w+)/i)[1]
But this just gives me "ABC". How can I match up to a whitespace?
Upvotes: 0
Views: 92
Reputation: 354
You can trim the string up to the whitespace first, then do your thing. So
str = str.substr(0, str.indexOf(" ")) // str is "Format-ABC-D"
Upvotes: 0
Reputation: 664548
Match anything else than whitespaces, not just word characters:
/Format-(\S+)/i
Upvotes: 2