I would like to extract paths in the form of:
$/Server/First Level Folder/Second_Level_Folder/My File.extension
The challenge here is that the paths are embedded in a "free form" email like so:
Hello,
You can download the file here:
- $/Server/First Level Folder/Second_Level_Folder/My File.extension <- Click me!
Given a string, I would like to extract all paths from it using RegEx. Is this even possible?
Thanks!
Yes, this is possible (\$/.*?\.\S*)
should do the job just fine.
\$/
matches the start of the path
.*?
matches everything till the next part of the regex
\.\S*
matches the dot and anything but a whitespace (space, tab)
And the (
)
around it make it capture all that is matched.
EDIT:
For further use
Just the path
(\$/.*?/)[^/]*?\.\S*
Just the filename
\$/.*?/([^/]*?\.\S*)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With