How to Ensure a String has no digits

onlyforthis

I have a string and want to make sure it does not contain digits. Is there a method in the String library that does it or i have to implement it myself?

Avinash Raj

You could use string.matches function to check for whether a string contains at-least one digit or not.

string.matches("\\D+");

This will return true for the strings which won't contain any single digit. \\D matches any non-digit character. So, \\D+ matches one or more non-digit characters. By passing it to matches method, it would apply the regex against the whole string.

DEMO

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to know if a word in a string has digits?

From Dev

Check if string has digits

From Dev

How to ensure a string has a substring exactly n times?

From Dev

How to check that a column values has string or digits values in mysql?

From Dev

How do i check if a string has a certain number of letters and digits?

From Dev

How to find digits in string

From Dev

Ensure that String has no sequences of a certain character (.)

From Dev

How to convert string to date format when string has only two digits for a year (Oracle, Netezza)

From Dev

How to ensure a string length in Ruby

From Dev

How to ensure object has only one thread

From Dev

How to ensure @PreAuthorize has been defined?

From Dev

How to verify if array has empty values or digits in it

From Dev

How to remove a text that has a certain number of digits?

From Dev

How to verify if array has empty values or digits in it

From Dev

Ensure a string representing a decimal number has a 0 before the "."

From Dev

i would like an error check to ensure that the string has vowels input

From Dev

How to move all digits in a string to the beginning of the string?

From Dev

How to match single digits and digits separated by a hyphen with string.match?

From Dev

How to ensure a textbox only accepts integers (and not string)

From Dev

Check if integer has repeating digits. No string methods or arrays

From Dev

How to only keep the first two digits of a string?

From Dev

How to create a type that describes string with only digits

From Dev

How to apply a custom mask into a string of digits in Python?

From Dev

How to convert string to decimal with specific number of digits

From Dev

How to format integer as string with 2 digits?

From Dev

How to get only Digits from String in mysql?

From Dev

How to create a type that describes string with only digits

From Dev

how to remove digits or numeric characters from the string

From Dev

How to check if certain digits exist in a string

Related Related

  1. 1

    How to know if a word in a string has digits?

  2. 2

    Check if string has digits

  3. 3

    How to ensure a string has a substring exactly n times?

  4. 4

    How to check that a column values has string or digits values in mysql?

  5. 5

    How do i check if a string has a certain number of letters and digits?

  6. 6

    How to find digits in string

  7. 7

    Ensure that String has no sequences of a certain character (.)

  8. 8

    How to convert string to date format when string has only two digits for a year (Oracle, Netezza)

  9. 9

    How to ensure a string length in Ruby

  10. 10

    How to ensure object has only one thread

  11. 11

    How to ensure @PreAuthorize has been defined?

  12. 12

    How to verify if array has empty values or digits in it

  13. 13

    How to remove a text that has a certain number of digits?

  14. 14

    How to verify if array has empty values or digits in it

  15. 15

    Ensure a string representing a decimal number has a 0 before the "."

  16. 16

    i would like an error check to ensure that the string has vowels input

  17. 17

    How to move all digits in a string to the beginning of the string?

  18. 18

    How to match single digits and digits separated by a hyphen with string.match?

  19. 19

    How to ensure a textbox only accepts integers (and not string)

  20. 20

    Check if integer has repeating digits. No string methods or arrays

  21. 21

    How to only keep the first two digits of a string?

  22. 22

    How to create a type that describes string with only digits

  23. 23

    How to apply a custom mask into a string of digits in Python?

  24. 24

    How to convert string to decimal with specific number of digits

  25. 25

    How to format integer as string with 2 digits?

  26. 26

    How to get only Digits from String in mysql?

  27. 27

    How to create a type that describes string with only digits

  28. 28

    how to remove digits or numeric characters from the string

  29. 29

    How to check if certain digits exist in a string

HotTag

Archive