It’s my first time using Java Script….
What does this do?
var INTEGER_SINGLE = /\d+/;
What does the forward slashes tell you? How about the backslash? d means for digit?
Thanks!
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
That creates a regular expression that matches one or more digits.
Anything inside
/ /is a regular expression.\dmatches a digit, and+is the positive closure, which means one or more.Having said that, depending on what this regex is supposed to do, you may want to change it to:
^matches the beginning of the string, and $ the end. The end result would be that any strings you try to match against the regex would have to satisfy it in the string’s entirety.Of course if the regex is supposed to only match a single integer anywhere in the string, then of course it’s perfect just the way it is.