-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var SysLocalPath = "/abc123z"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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