Solved

Regular expressions...

Posted on 2006-11-16
16
498 Views
Last Modified: 2010-08-05
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.
0
Comment
Question by:Wim ten Brink
  • 5
  • 5
  • 3
  • +2
16 Comments
 
LVL 15

Expert Comment

by:mikelittlewood
Comment Utility
Can you give us an example of something?
0
 
LVL 17

Author Comment

by:Wim ten Brink
Comment Utility
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.
0
 
LVL 15

Expert Comment

by:mikelittlewood
Comment Utility
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.
0
 
LVL 17

Author Comment

by:Wim ten Brink
Comment Utility
:-)

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...)
0
 
LVL 26

Accepted Solution

by:
Russell Libby earned 125 total points
Comment Utility

The closest thing you are going to get to "native" on a Win2K/XP box with IE6 is the vbscript.RegExp COM interface from vbscript.dll. Not that I can undestand why you would want to use it... as the COM overhead (not to mention its implementation) makes it much slower than a native code implementation of a regex parser.

Russell
0
 
LVL 26

Expert Comment

by:EddieShipman
Comment Utility
I agree with Russell. A regex DLL is MUCH faster than using any COM interfaced regex utility.
0
 
LVL 45

Expert Comment

by:aikimark
Comment Utility
the JavaScriptingRuntime can do it.
0
 
LVL 26

Expert Comment

by:Russell Libby
Comment Utility

True, but AFAIK the javascript/jscript regex is not exposed outside of the java environment...
0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 45

Expert Comment

by:aikimark
Comment Utility
it is registered as a COM object.  I've played with it in a VB application.
0
 
LVL 26

Expert Comment

by:Russell Libby
Comment Utility
What's the programmatic ID / interface ID for this?
0
 
LVL 45

Expert Comment

by:aikimark
Comment Utility
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.
0
 
LVL 17

Author Comment

by:Wim ten Brink
Comment Utility
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.
0
 
LVL 45

Assisted Solution

by:aikimark
aikimark earned 125 total points
Comment Utility
0
 
LVL 17

Author Comment

by:Wim ten Brink
Comment Utility
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. :-)
0
 
LVL 45

Expert Comment

by:aikimark
Comment Utility
Thanks for the points.

For your future planning and distribution, the .Net framework includes a regular expression class.
0
 
LVL 17

Author Comment

by:Wim ten Brink
Comment Utility
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. :-)
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
This video discusses moving either the default database or any database to a new volume.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now