Regex (Regular expression) To find if the string contains a numeric value.

Sometimes we have to validate if the user has entered a specific pattern or not, this pattern is validated by matching it with its regular expression.

  • To Find if any numeric value appears in a string:
/()\d()/

  • To Find if any 6 digits numeric number in a string:
/([^\d]|^)\d{6,}([^\d]|$)/

  • To Find any 6 digit number between the non-alpha-numeric value
/(?:^|\W)\d{6,100}(?:$|\W)/

Leave a Reply

Your email address will not be published. Required fields are marked *