Trevor
Trevor

Reputation: 35

Regex to match last occurrence

as i don't want to spend another hour googling forthe right regex: I want to remove the last backslash of a given string with gsub:

"C:\Program Files\".gsub(fancy_regex_here, '') # => "C:\Program Files"

Thanks in advance for any help

Upvotes: 3

Views: 1928

Answers (1)

Gopi
Gopi

Reputation: 10293

fancy_regex_here should be "\\$"

Upvotes: 6

Related Questions