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?
The symbol to make just one is optional whether it is Equivalent Java Regex: OR Equivalent Java regex: and call -
or .
may be.
- \ d {2} \. \ D {6}
- \\ d {2} \\. \\ d {6}
-? \ D {2} \. \ D {6}
-? \\ d {2} \\.
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
Post a Comment