Skip to content

Instantly share code, notes, and snippets.

@chluehr
Created July 22, 2010 14:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chluehr/486036 to your computer and use it in GitHub Desktop.
Save chluehr/486036 to your computer and use it in GitHub Desktop.
RegExp: Detect single/quoted string (w/ escapes) within strings
<?php
// detect single/quoted string (w/ escapes) within strings ..:
$regexp = '/(["\\\'])(?:\\\\?+.)*?\1/';
$testStr = " foo \"b\\\"ar\" baz '0\"8\"15' bing";
preg_match_all($regexp,$testStr,$matches);
print_r($matches);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment