Hi,
I am not sure you can use something like (^|\s)
and (\s|$)
, first -- maybe you can, but I have to thikn to understand the regex -- and it's never good when someone has to think to understand a regex : those are often quite too complicated :-(
If you want to match words that begins by "mso", be it upper or lowercase, I'd probably use something like this :
"class1 MsoClass2\tmsoclass3\t MSOclass4 msoc5".match(/\s?(mso[^\s]*)\s?/ig);
Which gets you :
[" MsoClass2 ", "msoclass3 ", " MSOclass4 ", "msoc5"]
Which is (almost : there are a couple white-spaces differences) what you asked.
Or, even simpler :
"class1 MsoClass2\tmsoclass3\t MSOclass4 msoc5".match(/(mso[^\s]*)/ig);
Which gets you :
["MsoClass2", "msoclass3", "MSOclass4", "msoc5"]
Whithout aby whitespace.
More easy to read / understand, too ;-)