473,386 Members | 1,693 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Parsing string with double and single quotes

I've been trying to devise a JavaScript function that will take a GPS latitude or longitude coordinate expressed as degrees, minutes and seconds, and convert it to decimal degrees. Once the expression is parsed, I've got no problems. My problem lies in converting a string like this:

110"57'9.62532

into its constituent parts, degrees, minutes and seconds. Since the string has an embedded double quote and an embedded single quote, my attempts to parse the string error out. I've searched the Web and this forum for a solution, to no avail. Can anyone suggest a solution? Thanks in advance for your help.
Sep 21 '07 #1
4 3223
pbmods
5,821 Expert 4TB
Heya, Joe. Welcome to TSDN!

This problem is right up the alley of Regular Expressions.
Sep 21 '07 #2
Thanks. That helps because it tells me I was on the right track. But as an inexperienced JavaScript programmer, I'm still lost. Any more direction that you can provide would be appreciated. In fact, give me an example to speed my learning.
Sep 24 '07 #3
pbmods
5,821 Expert 4TB
Heya, Joe.

No problem. The idea is that regular expressions are fantastic at describing strings.

So in the case of:
110"57'9.62532

We have:
  • a bunch of numbers
  • "
  • a bunch of numbers
  • '
  • a bunch of numbers with a '.' in the middle

Expressed as a regexp, we have:
Expand|Select|Wrap|Line Numbers
  1. alert( str.match(/^(\d+)"(\d+)'(\d+\.\d+)$/) );
  2.  
Sep 24 '07 #4
That helps a lot. Thanks for getting me on the right track.
Sep 25 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Nut Shell | last post by:
I needed to parse a csv file for my project. Could not find any so I put together this code. It works for general cases. Use it and let me know. Just Cut and paste the 2 functions in a new Form...
3
by: Stefania Scott | last post by:
How do I resolve the problem of passing a string that has quotes within in a SQL statement? Sometimes the string contains a single quote (') and some others it contains the double quote (")? Any...
5
by: Ann Marinas | last post by:
Happy New Year to all! :D I am currently developoing an application that imports data from a CSV file. Each comma represents an array item that I need to extract data with. My problem is...
6
by: G. | last post by:
This is an obvious bug in the String.Replace function: //load a XML string into a document XmlDocument doc = new XmlDocument(); doc.LoadXml("<test id='' />"); //Obtain the string...
12
by: Jeff S | last post by:
In a VB.NET code behind module, I build a string for a link that points to a JavaScript function. The two lines of code below show what is relevant. PopupLink = "javascript:PopUpWindow(" &...
1
by: Mark Rae | last post by:
Hi folks, Apologies - am having a bit of a "senior moment"... Is there a way to convert a string containing escaped characters into a verbatim string literal? I.e. converting something like...
8
by: Ian Davies | last post by:
Hello I have the following sql string to run as a command in my VB6 project to update mysql table strSQL = "LOAD DATA INFILE " & ImportFile & " INTO TABLE tPupils FIELDS TERMINATED BY ','...
17
by: Mark | last post by:
I must create a routine that finds tokens in small, arbitrary VB code snippets. For example, it might have to find all occurrences of {Formula} I was thinking that using regular expressions...
9
by: ankitdesai | last post by:
I would like to parse a couple of tables within an individual player's SHTML page. For example, I would like to get the "Actual Pitching Statistics" and the "Translated Pitching Statistics"...
4
by: Michael Yanowitz | last post by:
Hello: If I have a long string (such as a Python file). I search for a sub-string in that string and find it. Is there a way to determine if that found sub-string is inside single-quotes or...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.