I've looked at a lot of similar questions about this kind of problem but they haven't solved my problem...
This is the string that I've to match: "|6|" where the "6" is a variable that I've to put inside the regexp.
I've tried to create one (pid is the variable that contain the number):
var filter = new RegExp("/\|"+pid+"[\d*\]\|/");
It's look not working.. tryed with chrome console