I know this must be super simple but ...trying to match 2 use cases:
it can match this (exact)
var re = new RegExp("\\b" + name + "\\b");
or match this (same as above but MUST start with a space)
var re = new RegExp("^ \\b" + name + "\\b");
Actually the problem is that the string can contain multiple entries seperated by spaces like this
" somevar1 somevar2 somevar3 "
So when we pass name
to the regex above we want it to match either at the beginning of the string with a space
or at the beginning without space
..when we are not matching the beginning of the string (the rest), we do not test for a leading space
basically this "^ \\b" + name + "\\b|\\b" + name + "\\b"