Java: Match a string that contains only upper and lowercase letters, numbers, and underscores
8. Match Alphanumeric Underscore
Write a Java program to match a string containing only upper and lowercase letters, numbers, and underscores.
Sample Solution:
Java Code:
Sample Output:
Not matched! Found a match! Not matched! Found a match!
Pictorial Presentation:
Flowchart :
For more Practice: Solve these Related Problems:
- Write a Java program to verify that a string contains only letters, digits, and underscores using a regular expression.
- Write a Java program to implement a method that returns true if a string is alphanumeric with underscores and false otherwise.
- Write a Java program to test various strings against a pattern that allows only upper/lowercase letters, numbers, and underscores.
- Write a Java program to remove any characters from a string that are not letters, digits, or underscores.
Go to:
PREV : Match Word with Middle 'g'.
NEXT : String Starts with Specific Number.
Java Code Editor:
Contribute your code and comments through Disqus.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.