Reputation: 114
I want to split the path string based on the rightmost slash occurrence. The folders depths is variable - I can't know how many slashes I have. Is it possible to create the regex for this? I use it in HIVE queries for SPLIT function.
For example:
original string
/IP/backup_jun20_2017/proddb/application_profile/mth_end_dt=2016-10-31/000000_0
After split:
string 1:
/IP/backup_jun20_2017/proddb/application_profile/mth_end_dt=2016-10-31
string 2:
000000_0
Upvotes: 0
Views: 750
Reputation: 59978
Try to use this regex (.*)\/(.*?)$
or (.*)\/([^\/]+)
Which match two groups (.*)
the first one before the last slash, the second group after the last slash you can get it like this \/(.*?)$
or ([^\/]+)
Upvotes: 4