[uf-discuss] regexp for last path component

Toby A Inkster mail at tobyinkster.co.uk
Sat Jun 7 08:48:41 PDT 2008


Paul Denning wrote:

> Can someone provide a regexp for the last path component?


The following Perl-compatible regexp seems to do the trick:

	/^
	  [^\#\?]*         # Stuff at front (ignore)
	  \/([^\/]+)\/?    # Last path component
	  (\?.*)?          # Query string (ignore)
	  (\#.*)?          # Fragment (ignore)
	$/x

Use the first sub-pattern match as the tag.

-- 
Toby A Inkster
<mailto:mail at tobyinkster.co.uk>
<http://tobyinkster.co.uk>





More information about the microformats-discuss mailing list