NetBeans Forums

 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
  

Problem using String.split("[,]") method

 
Post new topic   Reply to topic    NetBeans Forums -> Java ME Users
View previous topic :: View next topic  
Author Message
lordbyron1960



Joined: 19 Apr 2015
Posts: 5
Location: Montgomery, AL

PostPosted: Sat Oct 10, 2015 6:48 pm    Post subject: Problem using String.split("[,]") method Reply with quote

String[] tokens = strNumbers.split("[,]");
for (String s : tokens)
System.out.print(s + " ");
Back to top
priya465



Joined: 17 Aug 2017
Posts: 28

PostPosted: Fri Sep 29, 2017 5:59 am    Post subject: Reply with quote

A dot is a special character in regular expression syntax. Use Pattern.quote() on the parameter to split() if you want the split to be on a literal string pattern:

String[] words = temp.split(Pattern.quote("."));
Back to top
Display posts from previous:   
Post new topic   Reply to topic    NetBeans Forums -> Java ME Users All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB
By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo