I have a little problem to obtain a regular expresion which satisfy the fact that match the exact number base on a list and the number is positive, at the beginning I was working with the following:
<!DOCTYPE html>
<html>
<body>
<script type="text/javascript">
var patt1=/\b(100|101)/g;
var str="-101";
document.write(str.match(patt1));
document.write("<br/>");
var str="101";
document.write(str.match(patt1));
</script>
</body>
</html>
But I realized that in this case it will return 101 and -101 as valid. Then I tried
var var patt1=/[^-]\b(100|101)/g;
but the result was null for both cases, then
var patt1=/(^-)\b(100|101)/g;
but the result instead of being null and then 101 was the opposite -101 null.
I want the 101 and not the -101 any idea about how to do this.
You can use this
regexIt excepts only
100or101as a valid input.But for this simply test, I would use: