473,395 Members | 1,738 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Regex and Hashtable

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.

Nov 23 '06 #1
1 1812
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
Nov 23 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Day Of The Eagle | last post by:
Jeff_Relf wrote: > ...yet you don't even know what RegEx is. > I'm looking at the source code for mono's Regex implementation right now. You can download that source here ( use the class...
5
by: francois | last post by:
First of all I would to to apologize for resending this post again but I feel like my last post as been spoiled Here I go for my problem: Hi, I have a webservice that I am using and I would...
1
by: kids_pro | last post by:
Hi there, Is it possible to use RegEx.Replace to replace string like this. string str = "The world heavy weight match"; I want to replace world = w and match = m I can do that with 2 line of...
8
by: rjb | last post by:
Hi! Could somebody have a look and help me to optimize the code below. It may look like very bad way of coding, but this stuff is very, very new for me. I've included just few lines. Regex...
33
by: Ken | last post by:
I have a C# Program where multiple threads will operate on a same Hashtable. This Hashtable is synchronized by using Hashtable.Synchronized(myHashtable) method, so no further Lock statements are...
2
by: D | last post by:
My first attempt at this and I'm searching formulas like so RIGHT(TEXT(A15,'yy'),1)*1000+A15-CONCATENATE(1,'-','jan','-',TEXT(A15,'yy'))+1 I want to extract the row / col coordinates (A15 in...
20
by: jeevankodali | last post by:
Hi I have an .Net application which processes thousands of Xml nodes each day and for each node I am using around 30-40 Regex matches to see if they satisfy some conditions are not. These Regex...
2
by: George Ter-Saakov | last post by:
Hi. I need some info where to look for following data object (aka map). It acts as a map but accept a Regexp as a key. (support of * and ? will be sufficient). So if i try look for string it...
2
by: PAzevedo | last post by:
I have this Hashtable of Hashtables, and I'm accessing this object from multiple threads, now the Hashtable object is thread safe for reading, but not for writing, so I lock the object every time I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.