var str = "<example>{{var=b|arg=args|link=c|testing=test1}}</example>";
How do I use regex to match args? In other words, I want to match the thing that follows arg= but before the next |.
var str = "<example>{{var=b|arg=args|link=c|testing=test1}}</example>";
How do I use regex to match args? In other words, I want to match the thing that follows arg= but before the next |.
var match = str.match(/arg=([^|]+)/);
Then check if match[1] exists. And if it does - then it contains what you want
UPD:
as @nnnnnn pointed out - instead of checking for match[1] presence it would be more correct to check if match is not null like:
if (match) {
// match[1] here contains required info
}
match[1] will give an error if there was no match: you have to test if match is null...