Skip to content

Instantly share code, notes, and snippets.

@tommcfarlin
Last active August 29, 2015 14:10
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 tommcfarlin/15ebb774e234a7457f31 to your computer and use it in GitHub Desktop.
Save tommcfarlin/15ebb774e234a7457f31 to your computer and use it in GitHub Desktop.
An example of how to use a regular expression to extract a piece of information from mixed HTML and JavaScript.
var SysLocalPath = "/abc123z";
<?php
// Request the response from the URL
$url_send = "https://dataquery.domain.com/?profile=$profil&acme=$data";
$result = file_get_contents( $url_send );
// Find the unique ID and store it in $matches
preg_match( "/(SysLocalPath)\s?(=)\s?(.*)/", $result, $matches );
<?php
$data_id = preg_replace( "/[^a-z0-9.]+/i", "", $matches[ count( $matches ) - 1 ] );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment