Results 1 to 3 of 3
Thread: Regex and split
- 02-13-2011, 11:54 PM #1
- Join Date
- Jan 2011
- Location
- Richmond, Virginia
- Posts
- 3,069
- Blog Entries
- 3
- Rep Power
- 7
Regex and split
I am trying to use split to split a String of the form
I want to split this up and store it in an array asJava Code:"Street Name: bob street, Address: 123 bob street, bar, loblah, 23456, Job Number: 32452"
my thought wasJava Code:anArr[0] == bob anArr[1] == street anArr[2] == 123 anArr[3] == bob anArr[4] == street anArr[5] == bar anArr[6] == loblah anArr[7] == 23456 anArr[8] == 32452
However, this leaves some blank spaces in array slots, I am going to be using this array to search and Im afraid the incorrect items will be added if there are blank strings in the array, anyone know of any way to split a string by spaces and the other items shown above? Thanks in advance for the help.Java Code:String[] anArr = item.toString().split(" |, |Name:|Job|Number:|Street|Address:");
- 02-14-2011, 12:01 AM #2
I'm no regex expert but i doubt this can be achieved with a single statement.
- 02-14-2011, 12:54 AM #3
Moderator
- Join Date
- Jul 2010
- Location
- California
- Posts
- 1,608
- Rep Power
- 5
Similar Threads
-
Regex help?
By l3ane in forum New To JavaReplies: 6Last Post: 01-18-2011, 06:04 AM -
How to use split?
By jeff_limsy in forum New To JavaReplies: 3Last Post: 12-29-2010, 09:23 AM -
Split a String with split()--Help
By danilson in forum New To JavaReplies: 7Last Post: 11-19-2010, 04:08 PM -
How to split a String using split function
By Java Tip in forum java.langReplies: 4Last Post: 04-17-2009, 08:27 PM -
How to split a String using split function
By JavaBean in forum Java TipReplies: 0Last Post: 10-04-2007, 09:32 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks