/ Match a literal '/' character ( The start of a capturing block ($1) .+? Match any character (except newline), one-or-more times (as few as possible) ) The end of $1 $ Match only if at end of string (or final newline) .... $1 = 'sham/b' Back-tracked within regex and rematched | VVV //(.+?)$/ | V 'ro/sham/bo' ^^^^^^^ [Visual of regex at 'rxrx' line 0] [step: 35] ####### $1 = 'sham/bo' End of $1 | V //(.+?)$/ | V 'ro/sham/bo' \_____/ [Visual of regex at 'rxrx' line 0] [step: 36] ####### $1 = 'sham/bo' Testing if at end of string (or final newline) | V //(.+?)$/ | V 'ro/sham/bo' [Visual of regex at 'rxrx' line 0] [step: 37] ####### $1 = 'sham/bo' Assertion satisfied | V //(.+?)$/ | V 'ro/sham/bo' [Visual of regex at 'rxrx' line 0] [step: 38] ####### $1 = 'sham/bo' Regex matched in 39 steps | V //(.+?)$/ | V 'ro/sham/bo' [Visual of regex at 'rxrx' line 0] [step: 39]