About 12,200,000 results
Open links in new tab
  1. Java String split() Method - GeeksforGeeks

    Apr 11, 2025 · The String split() method in Java is used to split a string into an array of substrings based on matches of the given regular expression or specified delimiter. This method returns a string array containing the required substring. Example: Here, we will split a String having multiple delimiters or regex into an array of Strings. Java

  2. Java String split() Method - W3Schools

    The split() method splits a string into an array of substrings using a regular expression as the separator. If a limit is specified, the returned array will not be longer than the limit. The last element of the array will contain the remainder of the string, which may still have separators in it if the limit was reached.

  3. How do I split a string in Java? - Stack Overflow

    Nov 20, 2016 · public static String[] split(String str, char separatorChar); In your case, you want to split a string when there is a "-". You can simply do as follows: String str = "004-034556"; String split[] = StringUtils.split(str,"-"); Output: 004 034556

  4. Split a String in Java - Baeldung

    Jan 8, 2024 · We can split a string into two parts by getting its midpoint and using substring() to get the separated parts. Here’s an example that splits a string in half: String hello = "Baeldung"; int mid = hello.length() / 2; String[] parts = { hello.substring(0, mid), hello.substring(mid) };

  5. How to Split a String in Java with Delimiter? - GeeksforGeeks

    Nov 19, 2024 · In Java, the split () method of the String class is used to split a string into an array of substrings based on a specified delimiter. The best example of this is CSV (Comma Separated Values) files. Here is a simple program to split a string …

  6. Java String split() : Splitting by One or Multiple Delimiters

    Oct 12, 2023 · This Java String tutorial taught us to use the syntax and usage of Spring.split() API, with easy-to-follow examples. We learned to split strings using different delimiters such as commas, hyphens, and even multiple delimiters in a String.

  7. java - Use String.split () with multiple delimiters - Stack Overflow

    It's best to only include the actual delimiter, instead of a "grab all" with \W. The string you give split is the string form of a regular expression, so: String[] tokens = pdfName.split("[-.]"); // ... That means "split on any character within the [] " (so, split on - and .). A couple of notes on that:

  8. Different Ways to Split a String in Java - HowToDoInJava

    Jan 8, 2023 · Learn to split a String with delimiters in Java using String.split (), StringUtils.split () and Splitter.split () APIs with examples. Learn to split or tokenize a string into an array.

  9. Java String split() Method with examples - BeginnersBook

    Dec 1, 2024 · Java String split method is used for splitting a String into substrings based on the given delimiter or regular expression. For example: Regular Expression: @ Output Substrings: {"chaitanya", "singh"} We have two variants of split() method in String class. 1.

  10. Java String split() Examples on How To Split a String With …

    Dec 6, 2020 · As part of String API features series, You'll learn how to split a string in java and also how to convert a String into String array for a given delimiter.

Refresh