![]() |
|
|
#1 |
![]() Join Date: Jun 2008
Location: England
Posts: 990 (0.55/day)
Thanks: 166
Thanked 76 Times in 72 Posts
|
Split String - Java
Hi all,
I've created a program to split a string which contains latitude coordinates. Code:
String[] temp;
String delimiter = "°";
temp = MetaData.latitude.split(delimiter);
for (int i = 0; i < temp.length; i++) {
System.out.println(temp[i]);
}
The program above will only do up to 97. I was thinking of using a loop, but unsure how to go about doing it. Any input would be helpful. Cheers
|
|
|
|
|
|
#2 |
|
Hardcore Monkey Moderator
Join Date: Feb 2007
Location: Cheeseland (Wisconsin, USA)
Posts: 12,254 (5.27/day)
Thanks: 591
Thanked 5,510 Times in 2,948 Posts
|
You could try using the regex or operator.
Code:
String[] temp = MetaData.latitude.split("°|\\'|\\"")
__________________
Cloud (noun, singular): A dynamic arrangement of multiple potential single points of failure, with a user at one end and their data at the other. Get more tech news on a wide variety of topics at NextPowerUp
|
|
|
|
|
|
#3 |
|
Benevolent Dictator
Join Date: May 2004
Location: Stuttgart, Germany
Posts: 13,873 (4.17/day)
Thanks: 184
Thanked 10,454 Times in 3,219 Posts
|
you definitely want to use a regular expression for this. to parse the whole thing, dont split
|
|
|
|
|
|
#4 | |
![]() Join Date: Sep 2008
Location: VA/PA
Posts: 500 (0.29/day)
Thanks: 139
Thanked 164 Times in 121 Posts
|
Quote:
Code:
String[] temp = MetaData.latitude.split("°|\'|\"")
__________________
![]() Made by PVTCaboose1337 |
|
|
|
|
| The Following User Says Thank You to Maelstrom For This Useful Post: |
|
|
#5 | |
|
Hardcore Monkey Moderator
Join Date: Feb 2007
Location: Cheeseland (Wisconsin, USA)
Posts: 12,254 (5.27/day)
Thanks: 591
Thanked 5,510 Times in 2,948 Posts
|
Quote:
I'm also not sure what he plans on doing with the coordinates once they are split out. He should put them in a float array if he will need to do calculation with them.
__________________
Cloud (noun, singular): A dynamic arrangement of multiple potential single points of failure, with a user at one end and their data at the other. Get more tech news on a wide variety of topics at NextPowerUp
|
|
|
|
|
|
|
#6 |
![]() Join Date: Jun 2008
Location: England
Posts: 990 (0.55/day)
Thanks: 166
Thanked 76 Times in 72 Posts
|
|
|
|
|
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| String problem with c++ game | Aleksander | Programming & Webmastering | 42 | Sep 26, 2011 06:08 PM |
| A Little String Help Needed | dcf-joe | Programming & Webmastering | 4 | Feb 10, 2010 04:39 AM |
| grep & hidden string alias' | Viscarious | Linux / BSD / Mac OS X | 3 | Sep 28, 2009 02:13 AM |
| Symantec corprate a/v scan string | [I.R.A]_FBi | General Software | 7 | Jul 25, 2007 04:59 PM |