This is a regular expression. The one you inserted will correspond to a positive / negative integer or correspond to the infinity of the word. In short, regex:
A regular expression (regular expression or regular expression for short) is a special string text to describe a search pattern. You can think of regular expressions as wildcards on steroids.
http://www.regular-expressions.info/
You often see regular expressions written as /expression_here/ because these slashes in many programming languages โโare an abbreviated way for developers to create regular expression objects.
You can create a simple expression to match a number with something like:
/^[0-9]*$/.test('44') // returns true
and
/^[0-9]*$/.test('asdasd') // returns false
Expressions like these and those similar to the one you inserted are processed and converted into small machines (called machines with final state ). the whole purpose of the machine is to determine if the string matches the expression represented by the machine, or if it does not match. Then you can pass the string to such a machine, and it will return the answer to you.
In our example above, we root lines 44 and asdasd in the regular expression /^[0-9]*$/ using the test method and returns true because 44 matches the expression and false for asdasd because it does not match.
We can also break up the regex that you included in your post:
^ means regular expression must match starting at VERY beginning of line
(\-|\+) means the beginning at the beginning of the line and matching either - or + , a question mark means that this part is optional
[0-9]+|Infinity means "match one or more numbers from 0 to 9", OR ( | ) matches the text of Infinity
$ means "and then requires the line to end here"