PHP regular match backslash '\' and dollar '$', php slash
This example describes the PHP Regular Expression matching method with the backslash '\' and dollar '$. We will share this with you for your reference. The details are as follows:
1. test. php:
<? Php $ content = '2017 <td> 1111111 <\/td> 3 $ '; // '\\\\\\/'100' \ 'escape string 100 '\', the string is '\' // 3rd ''\ 'to escape 4th'' \', which is equivalent to the string '\' // 5th ''\ 'to escape 4th '/', equivalent to the string '/' // character combination as '\/' Two '\' regular expressions as '\' $ pattern = '/<td> ([0-9] {7 ,}) <\\\\\/td> \ d \\$ $/'; $ result = preg_match_all ($ pattern, $ content, $ match_result); if ($ result) print_r ($ match_result); else echo ("not match ");
2. Method 2:
$content = '1111111<td>2222222<\/td>3$';$pattern = "!<td>(\d{7,})<\Q\/\Etd>\d\Q$\E!";$result = preg_match_all($pattern, $content, $m);if($result) print_r($m);else echo("not match");
3. Running result:
Array( [0] => Array ( [0] => <td>2222222<\/td>3$ ) [1] => Array ( [0] => 2222222 ))
PS: here we will provide two very convenient Regular Expression tools for your reference:
JavaScript Regular Expression online testing tool:
Http://tools.jb51.net/regex/javascript
Regular Expression generation tool:
Http://tools.jb51.net/regex/create_reg