Skip to content

Instantly share code, notes, and snippets.

@gayanvirajith
Last active April 27, 2017 08:44
Show Gist options
  • Save gayanvirajith/47d21e48b8c8cff3c2e533ac8a1a4e68 to your computer and use it in GitHub Desktop.
Save gayanvirajith/47d21e48b8c8cff3c2e533ac8a1a4e68 to your computer and use it in GitHub Desktop.
Regext to get []
var a = "@[a b: 222] hi there @[bob barker:11123] @[kyle corn:123] @[kenny logins:123ab-123]"
var extract = a.match(/@\[(.*?)\]/g); // With @ symbol
var extract = a.match(/\[(\.*?)\]/g); // Without @ symbol
extract.map(function (item) { var tempValue = item; tempValue = tempValue.replace(/\[|\]|@/g, ''); var kv = ''; return tempValue; });
extract.map(function (item) {
var tempValue = item;
tempValue = tempValue.replace(/\[|\]|@/g, '');
var kv = tempValue.split(':');
return '<a href="">'+ kv[0] + ' ' + kv[1] + '</a>';
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment