![]() |
Split a String while passing a regular expression (Regex) in the argument and a single String will split based on (Regex), as a result, we can store the string on the Array of strings. In this article, we will learn how to split the string based on the given regular expression. Example of Split String Using Regular Expression
Java Program to Split the String based on the Regular ExpressionFirst, we apply a String.split() on the given String and pass the given regex in the argument. It will return an Array of strings and we store it in the Array then we print the Array. Syntaxstr.split(regular_expression) Below is the implementation of the topic:Java
Output
hello from GeeksforGeeks Explaination of the above Program:
|
Reffered: https://www.geeksforgeeks.org
Java Programs |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 14 |