Q:

Regex to capture text after a specific char

I am trying to write a regex to capture all text after the final / in an expression e.g. for myname/is/john, I want to capture "john" but the regex I have written /[^/]*$ returns "/john". How can I get it to return just john and not /john?

A:

/([^/]*)$

You can use this and capture the group.

A:

If you can rely on the input to contain at least one /, then you can just match text that does not include it:
[^/]*$

You will get the maximal match.

