• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Strings Javacript

 
Ranch Hand
Posts: 285
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey all,
I have a string var which is
var gcc = "GCCOUNT count="1";
I want to extract the 1 from this. I tried in with Javascript, but no hope.
Can anyone please help me.
Thanks,
Maya
[This message has been edited by maya menon (edited September 05, 2001).]
 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can you give a few more details? Are you just trying to get whatever is to the right of the equals sign? If so, you could do something like:

This will find the index of the "= " in the string you provided and use that as a starting point to grab a substring. Since I gave no other parameter, it'll just grab the rest of the string from that point.
 
Shreya Menon
Ranch Hand
Posts: 285
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Bodie,
Thanks for the response.
Actually this is the string, which is an XML string from whivh I have to extract the value of the GCCOUNT tag.
var test = ' <?xml version="1.0"?> <ARCXML version="1.0"> <RESPONSE> <GEOCODE>
<FEATURE featureid="1">
<FIELD type="4" name="SCORE" size="5" precision="0"> <FIELDVALUE valuestring="100" /> </FIELD> <FIELD type="12" name="ADDRESSFOUND" size="17" precision="0"> <FIELDVALUE valuestring="2940N LINCOLN AVE" /> </FIELD> <FIELD type="-98" name="SHAPEFIELD"> <FIELDVALUE> <POINT x="1166877.68985714" y="1919619.76558407" /> </FIELDVALUE> </FIELD> </FEATURE> <GCCOUNT count="1" /> </GEOCODE> </RESPONSE> </ARCXML>';
From this I have to extract the value of the Geocode tag.
I have to do it using Javascript.
Thanks,
Maya
 
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi ,
You can cut the strings in to two part . One before the GCCOUNT and one after that. ( Use split fn of String ) . Tehn use indexOF and substrign to get the result.
regards,
srini
 
Slideshow boring ... losing consciousness ... just gonna take a quick nap on this tiny ad ...
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic