How to match the path separator {code...} How to Use preg_match () to match and output the variable $ win_dir. And how to match and output $ linux_dir. How to match \ or thank you !! Matching path Separators
$win_dir = 'C:\hello.txt';$linux_dir = '/home/hello.txt';
How to Usepreg_match()
Variable$win_dir
How to match\
And output. And$linux_dir
How to match/
And output. How to match\\
Or//
Thank you !!
Reply content:
Matching path Separators
$win_dir = 'C:\hello.txt';$linux_dir = '/home/hello.txt';
How to Usepreg_match()
Variable$win_dir
How to match\
And output. And$linux_dir
How to match/
And output. How to match\\
Or//
Thank you !!
For yourAnd Output
What does it mean ..
The above regular expression match\
Or/
Appears multiple times,
If exact match is required\\
Or//
, Use the following:
You do not need to use regular expression matching.DIRECTORY_SEPARATOR
You can,
DIRECTORY_SEPARATOR: Output System Separator
Windows platform output\
, Output on the Linux platform/