title: PHP regex to get WordPress category slug from $_SERVER['REQUEST_URI']
body: <p>I am trying to get the category slug from the <code>$_SERVER['REQUEST_URI']</code> using a pre_match pattern, but it's not working.</p>
  
  <p>For example, the <code>$_SERVER['REQUEST_URI']</code> returns <code>/category/current-affairs/</code> and I want to set <code>current-affairs</code> to a variable that I want to use.</p>
  
  <p>So far I came up with this but it's not working
  <code>^\/category\/(?:\/(\w+))*$/g</code></p>
  
  <p>Any help with this will be very much appreciated.</p>