I need to find all substrings like “something.somethingElse.get()” in a long string. I’m using match function in this way
myString.match(/\S+\.\S+\.get\(\)/);
It works, but returns only the first occurrence, so I have to split the string in some way to eliminate the firt part and repeat match again.
Is there a more efficient way to do this? I mean something like a search function that returns all substring in an array or an object
myString.match(/\S+\.\S+\.get\(\)/gi);You need to add global switch at the end of your regex.
https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/String/match (thanx, vcsjones)