Re: Correction
- From: "Dave Sexton" <dave@jwa[remove.this]online.com>
- Date: Fri, 18 Aug 2006 14:36:09 -0400
Hi Jules,
Check out how you can use "?" as a lazy modifier to existing quantifiers:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconquantifiers.asp
And negative lookbehind assertion:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpcongroupingconstructs.asp
Try this with the IgnorePatternWhitespace and Singleline options:
string pattern =
@"(?<sentence>.*? ) # lazily match sentence so that '.' does not capture eos
(?<eos> (?<! /) # negative lookbehind for /
/)?$ # match single '/' at end of string or just end of string";
--
Dave Sexton
"Jules" <eric.alexis.bruno@xxxxxxxxx> wrote in message news:1155863146.762496.119230@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Sorry, misspelling: please read "(?<sentence>.*(?<eos>[^\\][\\]{1}$)?)"
as "(?<sentence>.*(?<eos>[^/][/]{1}$)?)"
J.
Jules wrote:
All,
how do I describe a string consisting of any number of characters, with
an optional (but unique when occuring) end-of-line expression '/'? With
groups if possible, as in "(?<sentence>.*(?<eos>[^\\][\\]{1}$)?)"
Say I have the phrase 'My Taylor is /' as input; I'd like 'sentence'
and 'eos' to match.
Now if I have 'My Taylor is //' or 'My Taylor is / ', 'sentence' should
match, but not 'eos'. In other words, 'eos' should match only when it
occurs once, and last, in the string.
I have tried nesting eos within sentence, juxtaposing them, removing
quantifiers, removing the end-of-string assertion... nothing seems to
work satisfactorily.
Thanks for any help,
Jules
.
- Follow-Ups:
- Re: Correction
- From: Jon Shemitz
- Re: Correction
- References:
- Regex Help
- From: Jules
- Correction
- From: Jules
- Regex Help
- Prev by Date: Re: Applying CSS to asp:ListItem
- Next by Date: Re: Data Migration
- Previous by thread: Correction
- Next by thread: Re: Correction
- Index(es):
Relevant Pages
|