This matches at least one of the (nothing slashes) followed by the end of the line:
[^/]+$
Notes:
- There is no parence, because he does not need any groups - the result goes to group 0 (the match itself).
- Uses
+ (instead of * ), so if the last character is a slash, it does not match (and does not match an empty string).
But most likely, a quicker and simpler solution is to use the function of processing the list of strings built into the language, i.e. ListLast( Text , '/' ) or an equivalent function.
For PHP, the closest strrchr function, which works as follows:
strrchr( Text , '/' )
This includes a slash in the results - as per Teddy's comment below, you can remove the slash with substr :
substr( strrchr( Text, '/' ), 1 );
Peter Boughton Jul 19 '09 at 19:17 2009-07-19 19:17
source share