title: How can I delete parts of a JSON web response?
body: <p>I have a simple Perl script and I want to remove everything up to the word "city". Or remove everything up to the nth occurrence (the 2nd in my particular case) of the comma's " , ". Here's what is looks like below. </p>
  
  <pre><code>#!/usr/bin/perl
  use warnings;
  use strict;
  
  my $CMD = `curl http://ip-api.com/json/8.8.8.8`;
  chomp($CMD);
  my $find = "^[^city]*city";
  
  $CMD =~ s/$find//;
  
  print $CMD; 
  </code></pre>
  
  <p>The output is this:</p>
  
  <pre><code>{"as":"AS15169 Google Inc.","city":"Mountain View","country":"United States","countryCode":"US","isp":"Google","lat" :37.386,"lon":-122.0838,"org":"Google","query":"8.8.8.8","region":"CA","regionName":"California","status":"success","timezone":"America/Los_Angeles","zip":"94035"}
  </code></pre>
  
  <p>So i want do drop </p>
  
  <pre><code>" {"as":"AS15169 Google Inc."," 
  </code></pre>
  
  <p>or drop up to </p>
  
  <pre><code>{"as":"AS15169 Google Inc.","city":"Mountain View", 
  </code></pre>
  
  <h1>EDIT:</h1>
  
  <p>I see I was doing far too much when matching the string. I simplified the fix for my problem with removing all before "city". My $find has been changed to</p>
  
  <pre><code>my $find = ".*city";
  </code></pre>
  
  <p>While I also changed the replace function like so,</p>
  
  <pre><code>$CMD =~ s/$find/city/;
  </code></pre>
  
  <p>Still haven't figured out how to remove all before the nth occurrence of a comma or any character / string for that matter.</p>