The Artima Developer Community
Sponsored Link

Java Buzz Forum
How to Split String in Java with Example using Regular Expression

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Javin Paul

Posts: 450
Nickname: javinpaul
Registered: Jan, 2012

Javin Paul is Java Programmer working on Finance domain.
How to Split String in Java with Example using Regular Expression Posted: Mar 31, 2013 9:26 AM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by Javin Paul.
Original Post: How to Split String in Java with Example using Regular Expression
Feed Title: Java67
Feed URL: http://java67.blogspot.com/feeds/posts/default?alt=rss
Feed Description: Java and technology tutorials, tips, questions for all programmers.
Latest Java Buzz Posts
Latest Java Buzz Posts by Javin Paul
Latest Posts From Java67

Advertisement
String class provides split() method to split String in Java, based upon any delimiter, e.g. comma, colon, space or any arbitrary method. split() method splits string based on delimiter provided, and return a String array, which contains individual Strings. Actually, split() method takes a regular expression, which in simplest case can be a single word. split() is also overloaded method in java.lang.String class and its overloaded version takes a limit parameter which is used to control how many times pattern will be applied during splitting process. if this limit is positive n, then pattern will be applied at most n-1 times, if it's negative or zero than split operation is applied any number of time. For example, if we split String "First,Second,Third" on comma and provide limit as 2 then pattern will run one time, and split() will return String array with 2 Strings, "First" and "Second,Third". Since this method accepts a Java regular expression, it throws PatternSyntaxException, if syntax of regular expression is invalid.
Read more »

Read: How to Split String in Java with Example using Regular Expression

Topic: JArchitect became free for Java open source contributors Previous Topic   Next Topic Topic: MOXy’s Object Graphs – Input/Output Partial Models to XML & JSON


Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2014 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us