Could you tell me the grep pattern to match the following file path:
../any_directoryname/filename.txt
I only know the file name. any_directorynamekeeps changing.
any_directoryname
Thanks in advance,
Hi
John
Try the following:
\.\./[^/]+/filename.txt
This assumes only one directory. If it could be more, try
\.\./[^\r\n]+/filename.txt
try this regex
^\.\.\/[\w]+\/[\w\.]+$
,
str_replace('/filename.txt', '', $full_path);
, , ( , - , , ), , t , .
What about...
(Perl answer ...)
For a given path / file name in the form:
$fullPath = /dir/dir/dir/filename ($path, $file) = $fullPath =~ m/(^\/.*\/)(\S+$)/;
What puts
$path = /dir/dir/dir/... $file = filename