Помогите сделать регулярку

clocky

Client
Регистрация
26.09.2019
Сообщения
358
Благодарностей
48
Баллы
28
Всем привет, пытаюсь достать последние цифры - 18.8725252 . Регулярка - <lng> перед текстом и </lng></geometry> - после, но он берет первое значение - 18° 52' 21.09072. Я не понимаю почему, я же указываю что идет после искомого текста. Что делаю не так? Прошу помочь.


HTML:
<response><documentation>https://opencagedata.com/api</documentation><licenses><license><name>see attribution guide</name><url>https://opencagedata.com/credits</url></license></licenses><rate><limit>2500</limit><remaining>2498</remaining><reset>1722384000</reset></rate><results><result><annotations><DMS><lat>42° 17' 1.79664'' N</lat><lng>18° 52' 21.09072'' E</lng></DMS><MGRS>34TCM2458883482</MGRS><Maidenhead>JN92kg48qc</Maidenhead><Mercator><x>2100879.895</x><y>5174835.214</y></Mercator><NUTS><NUTS0><code>ME</code></NUTS0><NUTS1><code>ME0</code></NUTS1><NUTS2><code>ME00</code></NUTS2><NUTS3><code>ME000</code></NUTS3></NUTS><OSM><edit_url>https://www.openstreetmap.org/edit?node=312400297#map=17/42.28383/18.87253</edit_url><note_url>https://www.openstreetmap.org/note/new#map=17/42.28383/18.87253&amp;layers=N</note_url><url>https://www.openstreetmap.org/?mlat=42.28383&amp;mlon=18.87253#map=17/42.28383/18.87253</url></OSM><UN_M49><regions><EUROPE>150</EUROPE><ME>499</ME><SOUTHERN_EUROPE>039</SOUTHERN_EUROPE><WORLD>001</WORLD></regions><statistical_groupings>MEDC</statistical_groupings></UN_M49><callingcode>382</callingcode><currency><decimal_mark>,</decimal_mark><html_entity>€</html_entity><iso_code>EUR</iso_code><iso_numeric>978</iso_numeric><name>Euro</name><smallest_denomination>1</smallest_denomination><subunit>Cent</subunit><subunit_to_unit>100</subunit_to_unit><symbol>€</symbol><symbol_first>0</symbol_first><thousands_separator>.</thousands_separator></currency><flag></flag><geohash>srt2t3w91twtpuf0gysb</geohash><qibla>133.39</qibla><roadinfo><drive_on>right</drive_on><speed_in>km/h</speed_in></roadinfo><sun><rise><apparent>1722310620</apparent><astronomical>1722303600</astronomical><civil>1722308700</civil><nautical>1722306300</nautical></rise><set><apparent>1722362700</apparent><astronomical>1722369600</astronomical><civil>1722364560</civil><nautical>1722366960</nautical></set></sun><timezone><name>Europe/Podgorica</name><now_in_dst>1</now_in_dst><offset_sec>7200</offset_sec><offset_string>+0200</offset_string><short_name>CEST</short_name></timezone><what3words><words>strode.nonsense.unscrews</words></what3words><wikidata>Q2329119</wikidata></annotations><bounds><northeast><lat>42.3038324</lat><lng>18.8925252</lng></northeast><southwest><lat>42.2638324</lat><lng>18.8525252</lng></southwest></bounds><components><ISO_3166-1_alpha-2>ME</ISO_3166-1_alpha-2><ISO_3166-1_alpha-3>MNE</ISO_3166-1_alpha-3><ISO_3166-2>ME-05</ISO_3166-2><_category>place</_category><_normalized_city>Bečići</_normalized_city><_type>village</_type><continent>Europe</continent><country>Montenegro</country><country_code>me</country_code><county>Budva Municipality</county><postcode>85316</postcode><village>Bečići</village></components><confidence>7</confidence><formatted>85316 Bečići, Montenegro</formatted><geometry><lat>42.2838324</lat><lng>18.8725252</lng></geometry></result></results><status><code>200</code><message>OK</message></status><stay_informed><blog>https://blog.opencagedata.com</blog><mastodon>https://en.osm.town/@opencage</mastodon></stay_informed><thanks>For using an OpenCage API</thanks><timestamp><created_http>Tue, 30 Jul 2024 15:48:35 GMT</created_http><created_unix>1722354515</created_unix></timestamp><total_results>1</total_results></response>
 

Gunjubasik

Client
Регистрация
30.05.2019
Сообщения
3 473
Благодарностей
1 297
Баллы
113
Всем привет, пытаюсь достать последние цифры - 18.8725252 . Регулярка - <lng> перед текстом и </lng></geometry> - после, но он берет первое значение - 18° 52' 21.09072. Я не понимаю почему, я же указываю что идет после искомого текста. Что делаю не так? Прошу помочь.


HTML:
<response><documentation>https://opencagedata.com/api</documentation><licenses><license><name>see attribution guide</name><url>https://opencagedata.com/credits</url></license></licenses><rate><limit>2500</limit><remaining>2498</remaining><reset>1722384000</reset></rate><results><result><annotations><DMS><lat>42° 17' 1.79664'' N</lat><lng>18° 52' 21.09072'' E</lng></DMS><MGRS>34TCM2458883482</MGRS><Maidenhead>JN92kg48qc</Maidenhead><Mercator><x>2100879.895</x><y>5174835.214</y></Mercator><NUTS><NUTS0><code>ME</code></NUTS0><NUTS1><code>ME0</code></NUTS1><NUTS2><code>ME00</code></NUTS2><NUTS3><code>ME000</code></NUTS3></NUTS><OSM><edit_url>https://www.openstreetmap.org/edit?node=312400297#map=17/42.28383/18.87253</edit_url><note_url>https://www.openstreetmap.org/note/new#map=17/42.28383/18.87253&amp;layers=N</note_url><url>https://www.openstreetmap.org/?mlat=42.28383&amp;mlon=18.87253#map=17/42.28383/18.87253</url></OSM><UN_M49><regions><EUROPE>150</EUROPE><ME>499</ME><SOUTHERN_EUROPE>039</SOUTHERN_EUROPE><WORLD>001</WORLD></regions><statistical_groupings>MEDC</statistical_groupings></UN_M49><callingcode>382</callingcode><currency><decimal_mark>,</decimal_mark><html_entity>€</html_entity><iso_code>EUR</iso_code><iso_numeric>978</iso_numeric><name>Euro</name><smallest_denomination>1</smallest_denomination><subunit>Cent</subunit><subunit_to_unit>100</subunit_to_unit><symbol>€</symbol><symbol_first>0</symbol_first><thousands_separator>.</thousands_separator></currency><flag></flag><geohash>srt2t3w91twtpuf0gysb</geohash><qibla>133.39</qibla><roadinfo><drive_on>right</drive_on><speed_in>km/h</speed_in></roadinfo><sun><rise><apparent>1722310620</apparent><astronomical>1722303600</astronomical><civil>1722308700</civil><nautical>1722306300</nautical></rise><set><apparent>1722362700</apparent><astronomical>1722369600</astronomical><civil>1722364560</civil><nautical>1722366960</nautical></set></sun><timezone><name>Europe/Podgorica</name><now_in_dst>1</now_in_dst><offset_sec>7200</offset_sec><offset_string>+0200</offset_string><short_name>CEST</short_name></timezone><what3words><words>strode.nonsense.unscrews</words></what3words><wikidata>Q2329119</wikidata></annotations><bounds><northeast><lat>42.3038324</lat><lng>18.8925252</lng></northeast><southwest><lat>42.2638324</lat><lng>18.8525252</lng></southwest></bounds><components><ISO_3166-1_alpha-2>ME</ISO_3166-1_alpha-2><ISO_3166-1_alpha-3>MNE</ISO_3166-1_alpha-3><ISO_3166-2>ME-05</ISO_3166-2><_category>place</_category><_normalized_city>Bečići</_normalized_city><_type>village</_type><continent>Europe</continent><country>Montenegro</country><country_code>me</country_code><county>Budva Municipality</county><postcode>85316</postcode><village>Bečići</village></components><confidence>7</confidence><formatted>85316 Bečići, Montenegro</formatted><geometry><lat>42.2838324</lat><lng>18.8725252</lng></geometry></result></results><status><code>200</code><message>OK</message></status><stay_informed><blog>https://blog.opencagedata.com</blog><mastodon>https://en.osm.town/@opencage</mastodon></stay_informed><thanks>For using an OpenCage API</thanks><timestamp><created_http>Tue, 30 Jul 2024 15:48:35 GMT</created_http><created_unix>1722354515</created_unix></timestamp><total_results>1</total_results></response>
(?<=<lng>)\d+\.\d+(?=</lng>)
 
  • Спасибо
Реакции: clocky

Кто просматривает тему: (Всего: 1, Пользователи: 0, Гости: 1)