Parse Query Parameters

Retina, 30 27 bytes

!`(?<=^\1 .*[?&](.*)=)[^&]+

This is a full program that expects the key and the URL to be space-separated on STDIN, e.g.

action http://sub.example.com/some/dir/file.php?action=delete&file=test.foo&strict=true

This is essentially just a (.NET-flavoured) regex, which matches the correct value by checking that the preceding key is equal to the first string in the input (using a backreference). The only thing that's a bit odd about the regex is that .NET matches lookbehinds from right to left, which is why the "backreference" actually references a group that appears later in the pattern. The !` instructs Retina to print the actual match (if there is one) instead of the number of matches.

For those who don't regex, here is an annotated version. Read the lookbehind from the bottom up, because that's how it's processed:

(?<=        # A lookbehind. Everything we match in here will not be returned as part of
            # actual match. Start reading this from the corresponding parenthesis.
  ^         # Ensure we're at the beginning of the input, so that we've checked
            # against the entire input key.
  \1        # Backreference to the key to check that it's the one we've asked for.
  [ ]       # Match a space.
  .*        # Consume the rest of the URL.
  [?&]      # Match a ? or a & to ensure we've actually captured the entire key.
  (         # End of group 1.
    .+      # Match the key.
  )         # Capturing group 1. Use this to keep track of the key.
  =         # Make sure we start right after a '='
)           # Start reading the lookbehind here.
[^&]+       # Match the value, i.e. as many non-& characters as possible.

Pyth - 22 21 18 bytes

Uses the obvious method of constructing a dictionary and using } to check existence. Thanks to @FryAmTheEggman for the error handling trick.

#@.dcR\=cecw\?\&zq

Can probably be golfed a little more. Doing explanation now. Added explanation:

#                 Error handling loop
 @                Implicitly print dict lookup
  .d              Dictionary constructor, takes list of pairs
   cR\=           Map split with "=" as the second arg
    c    \&       Split by "&"
     e            Last in sequence of
      c           Split
       w          Second input
       \?         By "?"
 q                Quit loop

Try it online here.


JavaScript (ES6) 64

Edit Saved 1 byte thx @ismael-miguel

A function with url and key as parameters.

Test running the snippet in Firefox.

f=(u,k,e='')=>u.replace(RegExp(`[?&]${k}=([^&]*)`),(m,g)=>e=g)&&e

// TEST
out=x=>O.innerHTML += x+'\n';

test=[
   'https://example.com/index.php?action=delete',
   'https://this.example.com/cat/index.php?action=delete',
   'http://example.com', 
   'https://action.example.com/actionscript/action.jpg',
   'https://example.com/index.php?genre=action&reaction=1&action=2'
]

test.forEach(u=>out('Url '+u+'\nValue ['+f(u,'action')+']'))
<pre id=O></pre>