![]() |
Regex is a very interesting way to search for patterns in a String that the user provides. Regex stands for Regular Expressions. It consists of some patterns that can be planned and modified according to the usage of the program. In this article, we will discuss how to replace the first occurrence of a String using regex in Java. Example to Replace the First Occurrence of String
Java Program to replace the first occurrence of a String using regexBelow is the code implementation to replace the first occurrence of a String using regex: Java
Output
Original String: She is A Good Person . A good person is not always extraordinary Result String: She is A Extraordinary Person . A good person is not always extraordinary Explanation of the above Program:
|
Reffered: https://www.geeksforgeeks.org
Java |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 8 |