Re: Finding formatting items in a string
- From: Jesse Houwing <jesse.houwing@xxxxxxxxxxxxxxxx>
- Date: Mon, 18 Feb 2008 01:06:10 +0000 (UTC)
Hello Jack,
I even found a FAQ on this... I'm going to write a blogpost about this pattern at some poitn I guess. It has a lot of interesting regex things in it.
The FAQ:
http://msdn2.microsoft.com/en-us/netframework/aa569608.aspx
And a further completed regex, including the fact that you can use { and } within the custom pattern if you want to... Just escape them again. Which makes the whole escaping { harder and harder to understand...
This is the expression I've got so far:
(?<!([^\{]|^){({{)*){(?<item>[0-9]+)(?<alignment>,[-+]?[0-9]+)?(?<format>:([^{}]|{{|}})+)?}(?!}({{)*([^}]|$))
note also that I removed the \ before most, if not all of the { and } in the expression. It seems that the .NET regex parser is quite content with this. Only if the {n(,(m)?)?} format is used, do you need to escape the { and the }. I found that by accident. Not that it makes the expression any easier to read... *sigh*...
--
Jesse Houwing
jesse.houwing at sogeti.nl
.
- Follow-Ups:
- Re: Finding formatting items in a string
- From: Jesse Houwing
- Re: Finding formatting items in a string
- References:
- Re: Finding formatting items in a string
- From: Jesse Houwing
- Re: Finding formatting items in a string
- Prev by Date: Re: SV: Updating status label and status bar
- Next by Date: Re: SV: Updating status label and status bar
- Previous by thread: Re: Finding formatting items in a string
- Next by thread: Re: Finding formatting items in a string
- Index(es):
Relevant Pages
|