$re = '/^(?=.*\\\\)(?=.*\.)/m';
$str = 'I have the following string:
"\\Myfile.png"
I am trying to write a RegEx pattern, that must always match the \\ and . characters, if both characters are not present in the string, there should not be a match at all.
I need this for PowerShell, I have tried the following:
"\\MyFile.png" -Match "\\\\|\\."
But it always returns $True. I need it to be $True only if both \\ and . are present.
Thanks for any help.';
preg_match_all($re, $str, $matches, PREG_SET_ORDER, 0);
// Print the entire match result
var_dump($matches);
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for PHP, please visit: http://php.net/manual/en/ref.pcre.php