-7

I have some lines like this:

/gtrhr/5435-silent-library
/fghf3/435-silent-librar
/gfgr2gf/8768-silent-lib

How to get ONLY words in last part of URL ?

So, the oupout will be:

silent-library
silent-librar
silent-lib

Thank you !

1 Answers1

0
[A-Za-z][A-Za-z\-]+$

The $ enforces the match ends with the end of the line.

See here on Regexr.

You could also go for a more general [a-z][\w\-]+$ but that depends on precisely which characters are valid or not in your inputs.

Niels Keurentjes
  • 41,402
  • 9
  • 98
  • 136