Split String by Delimeter with Exceptions

I am wanting to split a string into an array where the delimiter is ; so I am using:

queryString() = Split(txtQuery.Text,";")

However my txtQuery.Text may contain strings with colons in-between " ; " or ’ ; ’ so I don’t want these to act as a delimiter for example I may have

Select * from tblTest; Select * from tblTest Where MyCol = ‘BR;BD’;

So I don’t want the semi colon between BR and BD to act as a delimiter.

How can I achieve this?

I have code in my M_String module that may help you. From memory, I think I called the methods NthFieldQuoted and CountFieldsQuoted. I might have SplitQuoted there too.

http://www.mactechnologies.com/downloads

[quote=80652:@Kem Tekinay]I have code in my M_String module that may help you. From memory, I think I called the methods NthFieldQuoted and CountFieldsQuoted. I might have SplitQuoted there too.

http://www.mactechnologies.com/downloads[/quote]

Thanks Kem, not had chance to test it out yet but a fantastic library of functions. I’m pretty sure it is what i’m after. Much appreciated