Regular expression get last characters

regex

Solution

It's as simple as:

[^/]+$

Which basically says: "give me all characters at the end that are not slashes".

Example:

$ echo 'http:// thesite.com/tester/blabla/this_is_the.jpg' | egrep -o '[^/]+$'
this_is_the.jpg

Problem

I want to write a regular expression which will take the characters from the last "slash" "/" to the right. Exemple1 : http:// thesite.com/tester/blabla/this_is_the.jpg - I want to extract only the "this_is_the.jpg" Exemple2 : http:// thesite.com/tester/blabla/this_is_2.jpg - Only the "this_is_2.jpg"

Original source

Related problems