Regex should be: ^\d{0,6}(\.\d{0,2})?$(It passed all of your samples)
Update:
To avoid empty string and single dot, regex is ^(?!\.?$)\d{0,6}(\.\d{0,2})?$. The expression adds a negative lookahead ?!\.?$, which excludes 0 or 1 dot.
Suppose I've a long string containing newlines and tabs as:
var x = "This is a long string.\n\t This is another one on next line.";
So how can we split this string into tokens, using regular expression?
I don't …
Given a string like so:
Hello {FIRST_NAME}, this is a personalized message for you.
Where FIRST_NAME is an arbitrary token (a key in a map passed to the method), to write a routine which would turn that string …
I know it's possible to match a word and then reverse the matches using other tools (e.g. grep -v). However, is it possible to match lines that do not contain a specific word, e.g. hede, using a regular …