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 / Languages / C# / August 2006

Tip: Looking for answers? Try searching our database.

RegEx question?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Thomas T. Veldhouse - 30 Aug 2006 16:52 GMT
I am looking for a regular expression that will match a string that contains
the word "clamp" but will not match if the string also contains the word
"arch".

So,

No Match:  "Arch Clamp"  "ArchClamp"  "archclamp"  "yada archie clamp"

Match:  "Clamp"  "sring clamp"  "deck clamp"

Is there an easy way to do this in a single expression?

Thanks in advance.

Signature

Thomas T. Veldhouse
Key Fingerprint: 2DB9 813F F510 82C2 E1AE  34D0 D69D 1EDC D5EC AED1

gpg - 30 Aug 2006 18:48 GMT
> I am looking for a regular expression that will match a string that contains
> the word "clamp" but will not match if the string also contains the word
[quoted text clipped - 13 lines]
> Thomas T. Veldhouse
> Key Fingerprint: 2DB9 813F F510 82C2 E1AE  34D0 D69D 1EDC D5EC AED1

Maybe something like this

(?i)(?-imsnx)^((?!(.*arch.*)).*(clamp))$

There is a fantastic tool called Expresso that I use to develop and
analyse regular expressions - it is even free.  Check out ultrapico.com

GPG
Thomas T. Veldhouse - 30 Aug 2006 19:08 GMT
> Maybe something like this
>
> (?i)(?-imsnx)^((?!(.*arch.*)).*(clamp))$

Thanks!  Very very close.  I had to remove the trailing $ as "clamps" is also
a match.

> There is a fantastic tool called Expresso that I use to develop and
> analyse regular expressions - it is even free.  Check out ultrapico.com

Tool looks great!  I haven't given it a try as of yet, but I did open the
tutorial.  I think there is a risk that my Regex skills might actually
decrease after this ;-)

Signature

Thomas T. Veldhouse
Key Fingerprint: 2DB9 813F F510 82C2 E1AE  34D0 D69D 1EDC D5EC AED1

gpg - 31 Aug 2006 16:48 GMT
No problem!

Expresso is extremely handy plus is will generate c# code for you based
on the regex that you develop.  Just the ability to run test matches
and build expressions makes this app a must in my toolbox.

GPG

> > Maybe something like this
> >
[quoted text clipped - 13 lines]
> Thomas T. Veldhouse
> Key Fingerprint: 2DB9 813F F510 82C2 E1AE  34D0 D69D 1EDC D5EC AED1

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.