Link to home
Start Free TrialLog in
Avatar of Wim ten Brink
Wim ten BrinkFlag for Netherlands

asked on

Regular expressions...

Well, something very simple. Yet as usual more complex than at first glance...

I am wondering if Windows 2000 and Windows XP have some COM-based control like MSXML for processing regular expressions. Yes, I know that there are plenty of Delphi components for handling regular expressions but I'm searching for something built-in by the operating system.

Why I'm not using some Delphi solution? Well, I actually have searched for several soltions and found plenty of options but someone suggested to me to also check if the Windows API has some standard function to use instead.

If no such API or COM library exists in Windows XP then too bad... Never hurts to ask anyways.
Avatar of Mike Littlewood
Mike Littlewood
Flag of United Kingdom of Great Britain and Northern Ireland image

Can you give us an example of something?
Avatar of Wim ten Brink

ASKER

Well, what I want to do is using regular expressions in my Delphi code. Well, not right away. I am to evaluate the build-in functionality of Windows on regular expressions so this is why I'm asking if Windows has some build-in support for regular expressions. And if it does, where? How?

I'm not interested in any third-part components for this. Plenty of options there. No, just the built-in functionality. It's purely for evaluation purposes to determine if I will have to use third-party components or if I can just use the Windows API for certain situations. I prefer to use built-in functionality if possible and am working on a code database to be used as reference for the company I work for. (And for me personally.) And I'm keeping any third-party solutions out of this code database.
Im still unsure what you want to do, probably my lack of knowledge of terminology.
I see you mentioned API, and I always thought that you could call any of the standard windows dll's for pretty much anything within delphi.

Think I better leave this one for another person.
:-)

Well, all I want to know if Windows has built-in functionality to use with regular expressions. So, basically assume you have a clean installation of Windows XP With Internet Explorer 6. Does this clean installation already have a library, a COM object or maybe just a Windows API to handle regular expressions? Or will I have to use third-party components for this?

With MSXML, for example, such a clean installation will have a DLL called MSXML.DLL in the System32 folder. This is a COM object which you can import in your project and it will provide lots of useful XML-related functions for you. I just wonder if there's something similar for regular expressions. (But it seems Microsoft itself isn't doing much with regular expressions...)
ASKER CERTIFIED SOLUTION
Avatar of Russell Libby
Russell Libby
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I agree with Russell. A regex DLL is MUCH faster than using any COM interfaced regex utility.
the JavaScriptingRuntime can do it.

True, but AFAIK the javascript/jscript regex is not exposed outside of the java environment...
it is registered as a COM object.  I've played with it in a VB application.
What's the programmatic ID / interface ID for this?
Russell,

While looking for this, I realized that your earlier VBScripting Regular Expression answer is the correct one.  I'm not sure what I was thinking of.  Please disregard my JavaScriptingRuntime suggestion.
Well, the only reason for using RegEx through COM would be because it can be done. That is, if a clean Windows XP installation (with IE6) already has some build-in support for it. There are of course many alternative solutions, some of them faster while others will be slower, but what I am working for is an overview of default Windows functionality.
And COM can be quite fast if you use early binding instead of late binding. :-) Unfortunately vbscript.dll doesn't make early binding very easy in my application. :-( But hey, it's one option. Are there more? :-)

If properly used, COM can be quite fast. Native code might be faster in some cases though but my experience with Delphi is that it's string-handling isn't really optimized for speed. Thus with things that have to process large strings (like XML files and regular expressions) I prefer to use alternative solutions that are either written in extremely optimized Delphi code (which is quite rare, actually) or written in a language like C++. Quality of the code matters too.

Btw, it doesn't have to be a COM-based solution. It just has to be a solution which is available on a clean Windows installation. :-) So a simple API call would be good enough too. Just as long as it doesn't depend on something third-party-like.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
http://www.swissdelphicenter.ch/en/showcode.php?id=1478 is the most interesting one. :-) For some reason I don't get a proper type library in Delphi 6 for this DLL. But then I noticed that importing this type library in Delphi results in multiple entries being added and the ones below the one I was looking at was the TRegExp class. :-)

So I found it! With the help of Russell and aikimark.

The other links from aikimark are quite good but Russell was the one pointing out the solution. So doubling the points, splitting them and yet another question closed. :-)
Thanks for the points.

For your future planning and distribution, the .Net framework includes a regular expression class.
Yeah, I know. I also know about several of the alternative solutions that you've provided but I just wanted to know if a built-in option was available and if it was, how to use it. :-) You and Russell provided that information.

The additional links are useful for any other members here ate EE who are interested in regular expressions, which is why I increased the points. :-)