Skip to content

Instantly share code, notes, and snippets.

@Vilintritenmert
Last active August 6, 2017 11:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Vilintritenmert/f29f5f2c0e111b43e040ad9925f5a5ea to your computer and use it in GitHub Desktop.
Save Vilintritenmert/f29f5f2c0e111b43e040ad9925f5a5ea to your computer and use it in GitHub Desktop.
Regexp
const first = arrayOfData.filter(item=>item.match(/r1/g))
.map(item => {
result = item.match(/r1/g);
return {
name:result[0],
surename:result[1]
};
});
const second = arrayOfData.filter(item=>item.match(/r2/g))
.map(item => {
result = item.match(/r2/g);
return {
name:result[0],
thirdname:result[1],
surename:result[2]
};
});
const users = [].concat(first, second);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment