|
Prev: ORA-00911 error and COMMIT
Next: Los Angeles Locksmith Services, Lockout Rekey Install Locks and Keys Made Home Car Auto
From: Malcolm Dew-Jones on 18 Jun 2008 19:29 stephen O'D (stephen.odonnell(a)gmail.com) wrote: : On Jun 16, 5:48 pm, Mtek <m...(a)mtekusa.com> wrote: : > Hi, : > : > I'm looking to parse an email. Say I have an email like this: : > : > johnjo...(a)gmail.abc.def.ghi.com : > : > I basically want johnjo...(a)gmail.abc.def.ghi in one variable and : > the .com in the other. : > : > If the email is this: : > : > jjo...(a)amail.co : > : > The same, I basically want jjo...(a)amail.co in one variable and : > the .com in the other. : > : > I know I have to use SUBSTR & INSTR, but the problem is that I do not : > know how many periods may be in the email address..... : > : > Any takers for some help?? : > : > Thanks! : > : > John : Depending on whether you are on Oracle 10G or not, regexp_instr and : regexp_substr may be a great help here - : http://www.oracle.com/technology/oramag/webcolumns/2003/techarticles/rischert_regexp_pt1.html INSTR( string_to_search , string_to_find , start_position , occurrence ) start_position can be negative, and then the search is backwards from the end. That allows you to find the last occurrence of a sub string. select instr( '12345678901234567890' , '8' , -1 ) from dual ; INSTR('12345678901234567890','8',-1) ------------------------------------ 18 $0.10 |