Jump to content
Celebr0

Parallelize Regex

Recommended Posts

Posted (edited)

Hello, I just started studying the OmniThreadLibrary library, but I can’t figure out how to parallelize this Regex procedure ?

 

procedure pars(const Regex: TRegEx; const str: string);
var
Match: TMatch;
begin
Match := Regex.Match(str);
//Parallel.ForEach(???).Execute( ???????????????
while Match.Success do
begin
//Match.Value;
Match := Match.NextMatch;
end;
end;

 

Edited by Celebr0

Share this post


Link to post

Parallelizing works well if you can break your overall job into multiple independent tasks, and each task can operate independently of the results of the other task. If the tasks depend on each other in any way, it becomes quite complex quite quickly, generally having to introduce locking and communication mechanisms.

 

In the case of RegEx parsing, how would you break your overall search into multiple independent searches. I dont see an easy way to do this. Each match depends on the results of previous matches. I am not saying it cannot be done, someone might have thought of something extremely clever, but its going to be complicated I think.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×