Splitting full path with regex

Would not class myself as a regex master and just starting learning about the intricacies of path names, was wondering if the following regex is standard for splitting a full-path into path only and name ?

full_path = "c:\folder\sub folder\filename.ext'

path_only = full_path.match(/^(.*[\\\/])/)

name_only = full_path.match(/[^\\]+$/)

also while we are on the subject what is the difference between
long and short files and paths args

Short paths are the old “8.3” style paths MS-DOS used.

I understand you are looking for a pattern within the string.
I would need to understand a little more about Jscript Regular Expressions to offer any comment on your syntax.

Happily, Evaluator RegEx is closer to the the Directory Opus RegEx syntax allowing New Name capture groups.

Really though, why not just just make an array of the full filepath and name?
Use \ as the array element separator and hence eliminate the \ characters.
It is then easy to rejoin the array elements as you want.
I amateurly programmed PHP many year ago and two commands I found very fun were Explode() which forms an array from a string using a common separator character. The inverse is Implode().

Well, I don't know enough of Dopus JScript to really answer your question, but I think Explode() and Implode() could be a good addition to Evaluator functions.

The regex look OK but, if you're using scripting, a better way to split up paths is the Path object provided by Opus:

https://docs.dopus.com/doku.php?id=reference:scripting_reference:scripting_objects:path

many thanks :slight_smile:

For paths, you can use Split() and Set().