Solved

Regular Expressions within SQL?

Posted on 2006-07-03
6
2,836 Views
Last Modified: 2008-01-09
Is it possible to incorporate regular expressions with SQL statements? For example, I want to return all records with a correctly constructed email address.

Cheers.
0
Comment
Question by:paulbradley
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 18

Expert Comment

by:Ravi Singh
ID: 17030768
I don't think the standard SQL supports complex regular expressions (someone can correct me if im wrong!) such as extracting valid email addresses, if your using some conventional high level programming language you could retrieve all email addresses using a select statement then iterate through these and find valid email addresses with the languages' support for regex's.

It also might be worth having a pointer to this question from a DB topic area
0
 
LVL 6

Accepted Solution

by:
Taconvino earned 250 total points
ID: 17030885
Hi!

I agree with Zephyr.  I don't think RegExp is supported by standard SQL.  You can look here:

http://www.sqlservercentral.com/columnists/mcoles/sql2000dbatoolkitpart2.asp

This is the second part of a very usefull article by Michael Coles.  I'm not sure, but I think it requires registration to look at (it's a free registration).

TCV
0
 
LVL 84

Expert Comment

by:ozo
ID: 17035205
MySQL supports
str REGEXP pat
but regular expressions are not very good for matching correctly constructed email addresses
doing it properly using a regular expression requires a pattern that's thousands of characters long.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 2

Expert Comment

by:eechincs
ID: 17040988
Agree with above,for me i rather have the detail validation on the emails format before inserting into the table.....then sure all the emails in the database are in correct format
0
 

Author Comment

by:paulbradley
ID: 17048849
Cheers for these remplies.

Basically I'm using Group Mail and linking it to an external database and using SQL queries to import only the data I'm interested in. I know I should validate as close to capture as possible but the database already has a high number of records and it's read only (it's the backend to my online shopping cart software).

I was hoping to be able to only import correctly constructed email addresses to minimise bouces, I don't think this seems possible without moving validation on to the web site - unless anyone can suggest anything?

Cheers.
0
 
LVL 1

Expert Comment

by:nicolasn
ID: 17049116
MS SQL 2005 supports user defined functions written in .Net languages.  You could get access to regular expressions like that if you are using the right verison of MS SQL.

I am not a DB expert, others may give better answers, but a UDF may be what you want.

Nicolas
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Help with a regex 3 74
Help Required 3 135
Formula for calculating ROI on training 6 92
Regex - Capture everything between two strings. 8 46
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.

739 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