ignore regex for "all but select dirs"

Michael Gliwinski Michael.Gliwinski at henderson-group.com
Mon Feb 1 11:15:06 GMT 2010


On Monday 01 February 2010 10:13:53 Michael Gliwinski wrote:
> Hello all,
>
> What I wanted to ask is if anyone managed to construct a regex to use in
> bzrignore file which selects all files/directories (or files matching some
> glob) except for some explicitly listed ones.
>
> I know the subject has been discussed before and John Whitley is working on
> ignore exclusions which might work for the purpose, it's just at the moment
> we have 2.0.x deployed and I need to find a stopgap solution at least.
>
> I'm asking here cause maybe someone has already done that so I could avoid
> re-inventing.
>
> A valid working regex would be something like:
>
>   '^(?!(?:dir1|dir2|dir3)\\b)'
>
> this works when matching with re.match, but when assembled into regex
> pattern by the Globster it ends up as:
>
>   '(?:(^(?!(?:dir1|dir2|dir3)\\b)))$
>
> which doesn't work.  Also tried without the '\b' when I noticed it
> automatically adds the '$' but no change.  It also doesn't work without
> the '^' (tried just in case).
>
> When I copy that regex from Globster, remove the '$' and use it with
> re.match, it works.
>
> Any ideas?

Never mind, only had the coffee now ;)  The answer is:

  '^(?!(?:dir1|dir2|dir3)\b).*'

Of course the '(?!x)' is non-consuming so when '$' is appended it effectively 
matches only an empty string.


-- 
Michael Gliwinski
Henderson Group Information Services
9-11 Hightown Avenue, Newtownabby, BT36 4RT
Phone: 028 9034 3319

**********************************************************************************************
The information in this email is confidential and may be legally privileged.  It is intended solely for the addressee and access to the email by anyone else is unauthorised.
If you are not the intended recipient, any disclosure, copying, distribution or any action taken or omitted to be taken in reliance on it, is prohibited and may be unlawful.
When addressed to our clients, any opinions or advice contained in this e-mail are subject to the terms and conditions expressed  in the governing client engagement leter or contract.
If you have received this email in error please notify support at henderson-group.com

John Henderson (Holdings) Ltd
Registered office: 9 Hightown Avenue, Mallusk, County Antrim, Northern Ireland, BT36 4RT.
Registered in Northern Ireland
Registration Number NI010588
Vat No.: 814 6399 12
*********************************************************************************




More information about the bazaar mailing list