-4

I want a regex for capturing latitude and longitude in some file say 52.5593266958818 and -1.9146537618027.

Sunil Kumar
  • 759
  • 7
  • 17
  • What you got so far? – kaveh Apr 13 '17 at 03:33
  • 1
    Why would you use regex for this? Can't you directly access the elements in question? Or are you trying to process the HTML shown as text? – nnnnnn Apr 13 '17 at 03:33
  • you're going to have to supply a **lot** more context to your question - and for the sake of everything sacred, I hope aren't embarking on path that could [summon "ZA̡͊͠͝LGΌ"](http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags/1732454#1732454) – Jaromanda X Apr 13 '17 at 03:37
  • I am using some software actually and not directly reading the file. the software is asking for regex. – Sunil Kumar Apr 13 '17 at 03:37
  • are you scraping somebodies website for data they don't want to share via conventional means? – Jaromanda X Apr 13 '17 at 03:38
  • hi you can treat this html as text only. and tell me how to use regex – Sunil Kumar Apr 13 '17 at 03:42
  • Hi I can use access specifiers to capture those values. but my aim is not that. I have use regex in some software for scraping. thank you – Sunil Kumar Apr 13 '17 at 04:26
  • 1
    @SunilKumar You need to update your actual question, not everyone reads the comments. – Zze Apr 13 '17 at 04:28

2 Answers2

1

The following will capture exactly those 2 numbers, no more no less.

/(52.5593266958818)|(-1.9146537618027)/g
52.5593266958818 // will capture
52.5593266958817 // will NOT capture
-1.9146537618027 // will capture
-1.9146537618026 // will NOT capture
Zze
  • 18,229
  • 13
  • 85
  • 118
0

I used

<div\sid="lat"\sstyle="display:\snone;">(.*)</div>

for lat value and

<div\sid="long"\sstyle="display:\snone;">(.*)</div>

for long value

these are general regex match

Sunil Kumar
  • 759
  • 7
  • 17