[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Regexp to parse "Version:" fields

On Wed, Jun 21, 2006 at 01:56:21PM +0200, Christoph Haas wrote:
> for mentors.debian.net I would like to find a perfect (TM) regular
> expression to split the "Version:" line of a control file into:
>  - epoch
>  - upstream version
>  - Debian package revision
> My current attempt is:
>    ^(?:(\d+):)?(\d[\w\.\+-:]*?)(?:-(.+))?$

You don't want to match a hyphen inside the Debian revision.  .+
will match it, [\w.+]+ won't.

1KB		// Microsoft corollary to Hanlon's razor:
		//	Never attribute to stupidity what can be
		//	adequately explained by malice.

Reply to: