I am looking to get value SPR2 from below string
var myString = "BUILDING - WITH DELETION OF EXCLUSION (d) & (e)<<SPR2>>"
please help
In the future, please identify what solutions you have tried before asking for assistance on Stack Overflow.
The expression you are looking for is (<{2}\\w+>{2})
, as demonstrated here .
You would then take a substring of each match and remove the << and >> characters.
Start to end, the solution would be as follows:
var str = 'BUILDING - WITH DELETION OF EXCLUSION (d) & (e)<<SPR2>>'; var regex = /<{2}(\\w+)>{2}/g; var matches = str.match(regex); matches.forEach(function(match) { console.log(match.substring(match.indexOf('<<') + 2, match.lastIndexOf('>>'))); });
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.