Codebox Software
RegEx DLL
Published:
RegEx.DLL provides some much needed regular-expression handling for VB programmers. The 'clsRegEx' class implements all the common UNIX wildcard characters allowing sophisticated string comparisons and search-and-replace operations to be performed.
- The '*' character represents zero or more occurrences of the previous character in the expression:
 ab*cmatches ac, abc, abbc, abbbbbbbc ...
- The '+' character represents one or more occurrences of the previous character in the expression:
 ab+cmatches abc, abbc, abbbbbbbc but not ac
- Numbers within curly brackets represent a specific number of occurrences of the previous character:
 a{3}matches aaaa{3,5}matches aaa, aaaa and aaaaa
- The '?' character represents zero or one occurrences of the previous character:
 a?cmatches ac and aac
- The '.' character represents any single character:
 a.cmatches abc, aXc but not ac or abbc
Round brackets can be used to apply multipliers, such as '*' or '+', to groups of characters:
- 
		(abc)*matches an empty string, abc, abcabc, abcabcabc ...
- 
		(abc)+matches abc, abcabc, abcabcabc ...
- 
		(a.c)*matches an empty string, abc, abcaXc, aXcaYcaZc ...
Square brackets can be used to specify possible values for a single character. A hyphen can be used in this context to represent a range of characters. If the first character within the brackets is a '^' then the range is exclusive rather than inclusive (ie. the expression matches any single character not shown):
- 
		a[bB]cmatches abc and aBc
- 
		a[0-9]cmatches a0c, a1c, a2c ... a9c
- 
		a[^0-9]cmatches abc and aXc but not a0c ... a9c
A '\' symbol negates the special meaning of the following character. Only valid if it precedes one of *+?\{([])}.
- 
		a\*cmatches a*c
- 
		a[\[\]]cmatches a]c and a[c
- 
		a\\cmatches a\c
- 
		>ab\cis not a valid expression
The download includes VB code samples demonstrating how to use the library.