- From: Robin Berjon <robin.berjon@expway.fr>
- Date: Tue, 01 Jul 2003 16:47:07 +0200
- To: Bill de hÓra <dehora@eircom.net>
- Cc: Colin Mackenzie <colin@elecmc.com>, xmlschema-dev@w3.org
Bill de hÓra wrote:
> Colin Mackenzie wrote:
>> but what is required is that pattern does not begin with a whole
>> string e.g. "STR1234" and "STRxccc" are bad (because of STR) but
>> "SAT1234" and "CARxccc" are good (not beginning with STR).
>>
>> I tried ^(STR) but this does not seem to work and
>>
>> [^S][^T][^R]
>>
>> does not allowe.g. "SAT"
>>
>> Any ideas please?
>
> You might be out of luck. Generally, you can't use a regular expression
> to negate strings.
Indeed. That sort of thing is usually done using zero-width assertions, in this
case probably a negative look-{ahead,behind} zero-width assertion. Those don't
actually contribute to the matching (hence the "zero-width") but can cause a
regex to fail based on additional criteria.
It might be a good idea to add those to XML Schema since I believe all sane
languages include it as part of their regex toolkit.
--
Robin Berjon <robin.berjon@expway.fr>
Research Engineer, Expway http://expway.fr/
7FC0 6F5F D864 EFB8 08CE 8E74 58E6 D5DB 4889 2488
Received on Tuesday, 1 July 2003 10:47:57 UTC