let rx = /(\/MxML\/[a-z0-9\[\]@/]*)/gi;
let s =
'If (/MxML/trades[1]/value== 1 then /MxML/trades[type=2]/value must be /MxML/stream/pre/reference@href';
let m;
let res = [];
while ((m = rx.exec(s))) {
res.push(m[1]);
}
console.log(res);
- Pattern should start with /MxML/
- Keep including acceptable characters [a-z0-9[]@/]
- A single
=is ok. But==or===are not ok.
Desired output
[
'/MxML/trades[1]/value',
'/MxML/trades[type=2]/value',
'/MxML/stream/pre/reference@href',
];
My current (incorrect) output
[
'/MxML/trades[1]/value',
'/MxML/trades[type',
'/MxML/stream/pre/reference@href',
];
I can think of a lookaround, but can't figure out how to use it here.
(?<!\=)\=(?!\=)
I've been going through several other examples on Stackoverflow, but they are about avoiding all character repetition and not about avoiding a particular character(=) repetition in conjunction with other valid characters.