Last active
April 27, 2017 08:44
-
-
Save gayanvirajith/47d21e48b8c8cff3c2e533ac8a1a4e68 to your computer and use it in GitHub Desktop.
Regext to get []
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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