Sorry for the daft question, but is the capture specifically CHECKVALUE_MIN_FROM_TOLERANCE_2_1... or is it anything between @@@?
e.g. /@@@(?<token>.+?)@@@/g
const text = `
Lorem, ipsum dolor sit amet consectetur adipisicing elit. Quas
repellendus doloremque @@@CHECKVALUE_MIN_FROM_TOLERANCE_2_1@@@
velit corporis, @@@CHECKVALUE_MIN_FROM_TOLERANCE_12_1@@@
quidem dolorem dicta ab necessitatibus animi labore veritatis
iure voluptates asperiores cumque.
`
const tokensRx = /@@@(?<token>.+?)@@@/g
// matchAll returns an iterator
for (const match of text.matchAll(tokensRx)) {
console.log(match.groups.token)
}
// "CHECKVALUE_MIN_FROM_TOLERANCE_2_1"
// "CHECKVALUE_MIN_FROM_TOLERANCE_12_1"
// accessing capture group at index 1
console.log(
Array.from(text.matchAll(tokensRx), (match) => match[1])
)
// ["CHECKVALUE_MIN_FROM_TOLERANCE_2_1","CHECKVALUE_MIN_FROM_TOLERANCE_12_1"]
// accessing capture group by name
console.log(
Array.from(
text.matchAll(tokensRx),
(match) => match.groups.token
)
)
// ["CHECKVALUE_MIN_FROM_TOLERANCE_2_1","CHECKVALUE_MIN_FROM_TOLERANCE_12_1"]
Its special on the tokens with TOLERANCE_MIN or TOLERANCE_MAX and then two numbers separated by an underscore where the second number can only be 1 or 2.