Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Extracting a string using Regular Expression

Status
Not open for further replies.

boy007

Programmer
Mar 28, 2006
3
GB
Is there a function to extract part of a string using a regular expression? Seems such a simple thing, but I don't seem to be able to find it anywhere. Not too keen on using substring, unless there is a good way of applying it.

It would be something like this (where "REGEX" is a function that takes a value and a regular expression, and "firstname" is the name of a column).

select id, REGEX(firstname, 'aa[a-z]*') from peopleTBL

might return:

***************************
ID Name
324 aardvark
***************************

Anyone know any alternatives?

Thanks.
 

All depends on your RDBMS, for Oracle try:
Code:
Select Id, Firstname
  From PeopleTBL
 Where REGEX_LIKE(Firstname, 'aa[a-z]*','i');
[3eyes]


----------------------------------------------------------------------------
The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top