Note that there are some explanatory texts on larger screens.

plurals
  1. PORegex only matching last occurrence
    primarykey
    data
    text
    <p>My regex is:</p> <p><code>genres\":\[(?=.*name\":\"(.*?)\"}(?=.*\"homepage))</code></p> <p>And my target is:</p> <pre><code>{ "adult":false, "backdrop_path":"/b9OVFl48ZV2oTLzACSwBpNrCUhJ.jpg", "belongs_to_collection": { "id":135468, "name":"G.I. Joe (Live-Action Series)", "poster_path":"/5LtZM6zLB2TDbdIaOC5uafjYZY1.jpg", "backdrop_path":"/m3ip0ci0TnX0ATUxpweqElYCeq4.jpg" }, "budget":185000000, "genres":[ { "id":28, "name":"Action" }, { "id":12, "name":"Adventure" }, { "id":878, "name":"Science Fiction" }, { "id":53, "name":"Thriller" } ], "homepage":"http://www.gijoemovie.com", "id":72559, "imdb_id":"tt1583421", "original_title":"G.I. Joe: Retaliation", "overview":"Framed for crimes against the country, the G.I. Joe team is terminated by Presidential order. This forces the G.I. Joes into not only fighting their mortal enemy Cobra; they are forced to contend with threats from within the government that jeopardize their very existence.", "popularity":11.7818680433822, "poster_path":"/swk1AHwPvIJv8NUFM1qpFuaT642.jpg", "production_companies":[ { "name":"Paramount Pictures", "id":4 }, { "name":"Metro-Goldwyn-Mayer (MGM)", "id":8411 } ], "production_countries":[ { "iso_3166_1":"US", "name":"United States of America" } ], "release_date":"2013-03-29", "revenue":371876278, "runtime":110, "spoken_languages":[ { "iso_639_1":"en", "name":"English" } ], "status":"Released", "tagline":"GI JOE IS NO MORE", "title":"G.I. Joe: Retaliation", "vote_average":5.4, "vote_count":1806 } </code></pre> <p>I know that it's JSON, and I should use a JSON class or something better than Regex to work with it, but, in this project I'm limited to Regex.</p> <p>I'm testing my Regex with <a href="http://regexhero.net/tester/" rel="nofollow">http://regexhero.net/tester/</a> and I only get <code>Thriller</code>, when I should get <code>Action, Adventure, Science Fiction, Thriller</code>, all of them.</p> <p>PS: I'm using Java and java.util.regex</p> <pre><code>List&lt;String&gt; generos = new ArrayList&lt;&gt;(); Matcher filter = Pattern.compile("genres\":\\[(?=.*name\":\"(.*?)\"}(?=.*\"homepage))").matcher(response); while (filter.find()) { generos.add(filter.group(1)); } </code></pre> <p>The code is totally fine, the only problem is in the regex. Just try this regex in any Regex Tester, and you will see that it only gets the LAST occurrence, but I need ALL of them.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload