0% found this document useful (0 votes)
16 views

Java Regular Expression

This document contains examples of regular expression exercises in Java with explanations and solutions. There are 12 examples that cover topics like matching characters, lowercase sequences, uppercase followed by lowercase, strings starting with a number, replacing substrings, and validating formats.

Uploaded by

Suat UĞURLU
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views

Java Regular Expression

This document contains examples of regular expression exercises in Java with explanations and solutions. There are 12 examples that cover topics like matching characters, lowercase sequences, uppercase followed by lowercase, strings starting with a number, replacing substrings, and validating formats.

Uploaded by

Suat UĞURLU
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Genel

Java Regular Expression: Exercises, Practice,


Solution
Last update on August 19 2022 21:50:53 (UTC/GMT +8 hours)

Java Regular Expression [30 exercises with solution]


1. Write a Java program to check whether a string contains only a certain set
of characters (in this case a-z, A-Z and 0-9). Go to the editor
Click me to see the solution

2. Write a Java program that matches a string that has a p followed by zero or
more q's. Go to the editor
Click me to see the solution

3. Write a Java program to find sequences of lowercase letters joined with a


underscore. Go to the editor
Click me to see the solution

4. Write a Java program to find the sequences of one upper case letter
followed by lower case letters. Go to the editor
Click me to see the solution

5. Write a Java program that matches a string that has a 'p' followed by
anything, ending in 'q'. Go to the editor
Click me to see the solution

6. Write a Java program to check a word contains the character 'g' in a given
string. Go to the editor
Click me to see the solution

7. Write a Java program that matches a word containing 'g', not at the start or
end of the word. Go to the editor
Click me to see the solution

8. Write a Java program to match a string that contains only upper and
lowercase letters, numbers, and underscores. Go to the editor
Click me to see the solution

Genel
Genel

9. Write a Java program where a string starts with a specific number. Go to


the editor
Click me to see the solution

10. Write a Java program to remove leading zeros from a given IP


address. Go to the editor
Click me to see the solution

11. Write a Java program to check for a number at the end of a given


string. Go to the editor
Click me to see the solution

12. Write a Java program to replace Python with Java and code with coding in
a given string. Go to the editor
Click me to see the solution

Genel

You might also like