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# / March 2008

Tip: Looking for answers? Try searching our database.

vs.net find help, how to search for all lines that contain 2 strings     using regex?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
DotNetNewbie - 05 Mar 2008 19:42 GMT
Hello,

In VS.NET, I assume the 'Find' tool lets you search using regular
expressions right?

How would I search for all lines in my project that contain 2 strings
(anywhere in the line, in any order)?

Example, the 2 strings could be: 1) script 2) text
Jesse Houwing - 05 Mar 2008 20:46 GMT
Hello DotNetNewbie,

> Hello,
>
[quoted text clipped - 5 lines]
>
> Example, the 2 strings could be: 1) script 2) text

Visual Studio uses a very nasty variation of Regex. Which is always very
frustrating for me to use. There are even 3rd party implementations of Find&Replace
which use the standard .NET flavour of regex instead.

The regex that works for me is:

{text.*script}|{script.*text}

--
Jesse Houwing
jesse.houwing at sogeti.nl
rossum - 05 Mar 2008 21:15 GMT
>Hello,
>
[quoted text clipped - 5 lines]
>
>Example, the 2 strings could be: 1) script 2) text

It might be simpler and more maintainable to separate the two
searches.

Pseudocode:

 for each string str in lines[] do
   if (str contains "script" and str contains "text") then
      doStuff(str)
   endif
 endfor

rossum

Rate this thread:







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.