Write a Java program to extract and print all domain names from a given text. Domains should
Question:
Write a Java program to extract and print all domain names from a given text. Domains should follow the format www.example.com or blog.example.net. Use a regular expression to capture these patterns.
(Here: the "given text" refers to a string containing various content, such as sentences, paragraphs, or any text data. The goal is to write a Java program that takes this text as input and extracts and prints all domain names following the specified formats (www.example.com or blog.example.net) using a regular expression.)
11. Write a Java program that utilizes a regular expression to count the occurrences of a specific substring in a given string. The program should prompt the user to enter both the main string and the substring to be counted. The regular expression should be used within the program to achieve the counting.
12. Write a Java program that checks whether a given string contains only alphabetic characters. Allow the user to input a string, and then use a regular expression to determine if the string contains only letters (no numbers or special characters).
Java An Introduction To Problem Solving And Programming
ISBN: 9780134462035
8th Edition
Authors: Walter Savitch