Regex Last occurrence?

Royi Namir picture Royi Namir · Dec 4, 2011 · Viewed 204.4k times · Source

I'm trying to catch the last part after the last backslash
I need the \Web_ERP_Assistant (with the \)

My idea was :

C:\Projects\Ensure_Solution\Assistance\App_WebReferences\Web_ERP_WebService\Web_ERP_Assistant


\\.+?(?!\\)      //  I know there is something with negative look -ahead `(?!\\)`

But I can't find it.

[Regexer Demo]

Answer

stema picture stema · Dec 4, 2011

Your negative lookahead solution would e.g. be this:

\\(?:.(?!\\))+$

See it here on Regexr