SQL Wildcards vs. Perl Regular Expressions

There is not much to say here: Perl has a great system for pattern matching and SQL does not. You have two very basic pattern matching operators in ANSI SQL, the percent sign ('%') which matches zero or more of any character and the underscore ('_') which matches any single character. Here are some equivalents:

SQL WildcardPerl Regex
LIKE 'L%'m/^L/
LIKE '%ing'm/ing$/
LIKE '%foo%'m/foo/
LIKE 'fo_'m/^fo.$/


Copyright © Joseph L. Casadonte Jr. 1998. All rights reserved.
SQL Wildcards vs. Perl Regular Expressions / 11 January 1998 / joc@netaxs.com