| [reply] |
Rather than using a regular expression, it's probably better to use the existing code base to do your job for you. In this case, the core module File::Spec can parse the path for you using the splitpath method.
However, if there's a good reason to do it with a regular expression, you can use:
/([^\\]*)$/
which will match and extract all the characters between the last backslash and the end of the string. Note this will fail on to do what you want on non-MS systems. See perlretut for more regular expression information. | [reply] [d/l] |
If you don't want to use File::Basename or File::Spec, you still shouldn't use regexen. Why use a complicated machine which many parameters, when what you want is a salami-slicer?
If you don't use the clean and simple tools, use split. Of course you have to decipher whether to split on '/' for Macs or unix, '\' for Windows, was it ':' on VMS?, or something else ... all that is handled for you if you use the right tool. After you split, just take the last component and that's the filename.
--
TTTATCGGTCGTTATATAGATGTTTGCA
| [reply] |