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# / November 2006

Tip: Looking for answers? Try searching our database.

Regex  and Hashtable

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
oshaer@nds.com - 23 Nov 2006 15:51 GMT
Shalom.

I need to go over a file, and check for each line if it matches a Regex
from a list of expressions.
(If it matches ANY of the expressions, this is good enough).

I have put the Regex's in an array, but it seems to take  too long  to
compare each line to all Regex's.

So i thought maybe there's a way to put Regex's in a hashtable, and
make the search for a match a bit faster.

If anyone has an idea how to do this, i will be happy to hear.

Thanks.
Ofira.
Marc Gravell - 23 Nov 2006 16:03 GMT
No; the hashtable would only help you retreive a *specific* regex from some
predefined key; has nothing to do with matching; the array was already
probably your best bet.

If in 2.0, you could consider compiling the Regex; this should help. Also
check for back-references and other expensive Regex things. Ensure you are
short-circuiting - i.e. if a line you've matches *one* Regex, then stop
looking. How are you processing the file? Line by line (StreamReader)? or as
an entire string? Finally, check if there are any logical short-cuts, i.e.
if it doesn't start like <x>, then it can't *possibly* match these 5 Regex,
so don't bother looking...

Marc

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.