Finding characters before last underscore
regex
Solution
`/(.*)_/` and take the value of the capture. Regexes are typically greedy so it's automatic (you don't need the negative character class).
`irb(main):007:0> "IABU_Real_Egypt_AUS09_012.indd".match(/(.*)_/)[1]`
`=> "IABU_Real_Egypt_AUS09"`
Problem
Does anyone know how to find all characters before the last underscore in a filename. IABU_Real_Egypt_AUS09_012.indd The result I need is IABU_Real_Egypt_AUS09 Thanks in advance