Home All Groups Group Topic Archive Search About
Author
29 Mar 2006 10:36 AM
Gustav
Hi!

I want to create a regex (using C#) that split a String where a +: or '
character is found except if the specified character is preceeded by a ?. The
? act as a do not split here sign.

Can anyone give me a hint how to create this regex.

regards / gustav

Author
29 Mar 2006 12:39 PM
Kevin Spencer
((?<!\?)\+)|((?<!\?)')

This regular expression looks for either of 2 possible matches: + or '.

It uses a negative lookbehind to assert that the character is not preceded
by a ?.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

Show me your certification without works,
and I'll show my certification
*by* my works.

Show quote
"Gustav" <Gus***@discussions.microsoft.com> wrote in message
news:BE46439E-9C21-4BAA-A408-CFFBB038F2A6@microsoft.com...
> Hi!
>
> I want to create a regex (using C#) that split a String where a +: or '
> character is found except if the specified character is preceeded by a ?.
> The
> ? act as a do not split here sign.
>
> Can anyone give me a hint how to create this regex.
>
> regards / gustav
Author
29 Mar 2006 1:46 PM
Gustav
Thanks alot!
solved it myself this way (?<!\?)('|\+|:)

Show quote
"Kevin Spencer" wrote:

> ((?<!\?)\+)|((?<!\?)')
>
> This regular expression looks for either of 2 possible matches: + or '.
>
> It uses a negative lookbehind to assert that the character is not preceded
> by a ?.
>
> --
> HTH,
>
> Kevin Spencer
> Microsoft MVP
> Professional Numbskull
>
> Show me your certification without works,
> and I'll show my certification
> *by* my works.
>
> "Gustav" <Gus***@discussions.microsoft.com> wrote in message
> news:BE46439E-9C21-4BAA-A408-CFFBB038F2A6@microsoft.com...
> > Hi!
> >
> > I want to create a regex (using C#) that split a String where a +: or '
> > character is found except if the specified character is preceeded by a ?.
> > The
> > ? act as a do not split here sign.
> >
> > Can anyone give me a hint how to create this regex.
> >
> > regards / gustav
>
>
>
Author
29 Mar 2006 5:15 PM
Kevin Spencer
Hi Gustav,

Yes, I didn't take the time necessary to optimize it well. But your solution
prompted me to come up with an even better one:

(?<!\?)['\+\:]

Rather than Or'ing the values together, put them into a character class.

Didn't notice the colon in the original list!

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

Show me your certification without works,
and I'll show my certification
*by* my works.

Show quote
"Gustav" <Gus***@discussions.microsoft.com> wrote in message
news:CD33F3B7-36BF-4F4B-A582-CDAC9AF7668A@microsoft.com...
> Thanks alot!
> solved it myself this way (?<!\?)('|\+|:)
>
> "Kevin Spencer" wrote:
>
>> ((?<!\?)\+)|((?<!\?)')
>>
>> This regular expression looks for either of 2 possible matches: + or '.
>>
>> It uses a negative lookbehind to assert that the character is not
>> preceded
>> by a ?.
>>
>> --
>> HTH,
>>
>> Kevin Spencer
>> Microsoft MVP
>> Professional Numbskull
>>
>> Show me your certification without works,
>> and I'll show my certification
>> *by* my works.
>>
>> "Gustav" <Gus***@discussions.microsoft.com> wrote in message
>> news:BE46439E-9C21-4BAA-A408-CFFBB038F2A6@microsoft.com...
>> > Hi!
>> >
>> > I want to create a regex (using C#) that split a String where a +: or '
>> > character is found except if the specified character is preceeded by a
>> > ?.
>> > The
>> > ? act as a do not split here sign.
>> >
>> > Can anyone give me a hint how to create this regex.
>> >
>> > regards / gustav
>>
>>
>>

AddThis Social Bookmark Button