Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Regex in VB6?

Tags:

regex

vb6

I need to write a program that can sift through specially-formatted text files (essentially CSV files with a fixed set of column types that have different delimiters for some columns ... comma in most places, colons in others) to search for formatting errors. I figure regular expressions will be the way to go.

The question: Is there a good regex library for VB6?

Thank you!

Edit: Holy crap, 3 responses in under an hour. Thanks a ton, folks! I've heard such good things about Regex Buddy from Jeff's postings / podcasting, that I will have to take a look.

like image 476
Ja7on Avatar asked Sep 04 '08 20:09

Ja7on


4 Answers

Use the Regex COM component built into Windows. You can find a step by step on referencing and using it in your project at: http://www.regular-expressions.info/vb.html

like image 85
t3rse Avatar answered Sep 30 '22 19:09

t3rse


Regex Buddy has a VB6 library

I use this in Delphi and it's very good - and Jeff has raved about RegexBuddy on several occasions.

I can't speak for the VB implementation, but it's certainly worth a look.

like image 25
robsoft Avatar answered Sep 30 '22 20:09

robsoft


As you probably know, VB6 didn't ship with a built-in regular expression library. You can, however, use one provided by an ActiveX or COM library. See this article for details.

like image 24
Bill the Lizard Avatar answered Sep 30 '22 19:09

Bill the Lizard


Other answers are correct, but link-only answers, so for convenience:

In File → References, add the "Microsoft VBScript Regular Expressions 5.5" library:

screenshot

Now you can use the library in your code:

Dim matcher As RegExp
Set matcher = New RegExp
matcher.Pattern = "^super cool string$"
If matcher.Test(someString) Then
    '...do something...
End If

As usual, regular-expressions.info provides the best reference material.

like image 35
Michael Kropat Avatar answered Sep 30 '22 18:09

Michael Kropat