Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / March 2006

Tip: Looking for answers? Try searching our database.

Regex question

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Gustav - 29 Mar 2006 11:36 GMT
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
Kevin Spencer - 29 Mar 2006 13:39 GMT
((?<!\?)\+)|((?<!\?)')

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 ?.

Signature

HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

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

> Hi!
>
[quoted text clipped - 6 lines]
>
> regards / gustav
Gustav - 29 Mar 2006 14:46 GMT
Thanks alot!
solved it myself this way (?<!\?)('|\+|:)

> ((?<!\?)\+)|((?<!\?)')
>
[quoted text clipped - 13 lines]
> >
> > regards / gustav
Kevin Spencer - 29 Mar 2006 18:15 GMT
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!

Signature

HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

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

> Thanks alot!
> solved it myself this way (?<!\?)('|\+|:)
[quoted text clipped - 18 lines]
>> >
>> > regards / gustav

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.