I tried
/^[0-9](\w)*[$]{4,}$/
but it only accepts the string of having $$$$ at last.
CodePudding user response:
This should meet your requirements:
/^(?=.{4,})\d \$$/
The positive lookahead assertions can help you with restricting the length of string
CodePudding user response:
You can start the match with a digit, then match 2 or more word characters and end the match with a dollar sign.
That way the pattern has to match at least 4 characters.
^[0-9]\w{2,}\$$
If the whole string should be at least 4 characters, start with a digit and end with a dollar sign, you can use the dot to match any character.
^[0-9].{2,}\$$