java - What's wrong with my regex -?\\d{2}\\.?\\d{6} -


I am trying to extract the URL longer and longer:

 source: ... sensor = False & center = -15.842208999999999% 2C-48.0, 23,084 and zoom = 17 & size = 256x256 and language = hi & customer = google-map-frontend and signature = hbey3U4lycTNgX48asW8MODjJLM 

I regexes I'm not good at, so I went to the tester regex () and this regex coded

 -. \ D {2} \ \ d {6} 
(for Java)

that this result (which is in production, it is regexpal .com): < / P>

 -15.842208 ... -48.0, 23,084 

So when I do this (in Java):

  (element For element: NewsHeadlines) {if (element.toString (.) Contains ("https://maps.google.com")) {list & lt; String & gt; Lista = get_matches (element.attr ("content"), "-? \\ d {2} \\. \\ d {6}"); }} Public Stable List & lt; String & gt; Get_matches (string s, string p) {// return of all matches of p p for first group in returning expression list & lt; String & gt; Matches = new arrelisted & lt; String & gt; (); Matcher M = Pattern.compile (P). MISHER (S); While (m.find ()) {matches.add (m.group (1)); // & lt; - Exception m.group (1) has no results} Return match; }  

What's wrong with my regex?

itemprop = "text">

The symbol to make just one is optional whether it is - or . may be.

  - \ d {2} \. \ D {6}  

Equivalent Java Regex:

  - \\ d {2} \\. \\ d {6}  

OR

  -? \ D {2} \. \ D {6}  

Equivalent Java regex:

  -? \\ d {2} \\.  

and call m.group (0) to print only the matched wire if you If you want to call m.group (1) , then you have to include the pattern inside paapthiris.


Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -