Home » SQL & PL/SQL » SQL & PL/SQL » REGULAR_EXPRESSION query (Oracle 11g)
REGULAR_EXPRESSION query [message #632359] Thu, 29 January 2015 07:55 Go to next message
srinivas.k2005
Messages: 404
Registered: August 2006
Senior Member
Hi,

I am not familiar with regular expression, can anybody give some suggestion on below


select REGEXP_REPLACE('test<img border="0" src="http://www.efunds.com/web/img/interface/logo.gif" width="105" height="45">674545', '<img+>') FROM DUAL;

So i have standard like any thing between <img border......> should be replaced by null

Output I need:
'test674545'

Re: REGULAR_EXPRESSION query [message #632362 is a reply to message #632359] Thu, 29 January 2015 08:04 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
https://www.google.com/webhp?hl=en&tab=ww#hl=en&q=regular+expression+tutorial
Re: REGULAR_EXPRESSION query [message #632363 is a reply to message #632362] Thu, 29 January 2015 08:11 Go to previous messageGo to next message
Roachcoach
Messages: 1576
Registered: May 2010
Location: UK
Senior Member
select REGEXP_REPLACE('test<img border="0" src="http://www.efunds.com/web/img/interface/logo.gif" width="105" height="45">674545', '<img(.)+>',null) FROM DUAL;


Works for the single test case.

Also, be very careful when using regexp - there are a lot of weird things happen there depending on settings.
Re: REGULAR_EXPRESSION query [message #632364 is a reply to message #632363] Thu, 29 January 2015 08:13 Go to previous messageGo to next message
srinivas.k2005
Messages: 404
Registered: August 2006
Senior Member
Thanks, Sure will check for setting and behaviour.

Thanks a lot again
Re: REGULAR_EXPRESSION query [message #632369 is a reply to message #632364] Thu, 29 January 2015 08:48 Go to previous messageGo to next message
Lalit Kumar B
Messages: 3174
Registered: May 2013
Location: World Wide on the Web
Senior Member
@OP,

Almost 8 years around registered with OraFAQ, still such a poor way of posting a question. What about posting a test case? Please act professional.
Re: REGULAR_EXPRESSION query [message #632378 is a reply to message #632369] Thu, 29 January 2015 10:04 Go to previous messageGo to next message
Roachcoach
Messages: 1576
Registered: May 2010
Location: UK
Senior Member
It was, it was select <string> from dual.

Albeit a single row case!!! I could copy/paste and directly modify.
Re: REGULAR_EXPRESSION query [message #632382 is a reply to message #632378] Thu, 29 January 2015 10:43 Go to previous messageGo to next message
srinivas.k2005
Messages: 404
Registered: August 2006
Senior Member
Yeah i was looking for just one case of select statement and modified accordingly which i got exactly from Roachcoach, i kept simple things simple rather than making simple thing complicated.

More experience does not mean to make things complex Smile
Re: REGULAR_EXPRESSION query [message #632421 is a reply to message #632382] Fri, 30 January 2015 05:49 Go to previous message
Roachcoach
Messages: 1576
Registered: May 2010
Location: UK
Senior Member
Well the trouble is people typically oversimplify. There are literally countless threads on this forum where people post a question, a solution is posted and the immediate reply is "but that doesn't work for this case [which I've not told you about before]".

Which is why a detailed test case is good and why I caveated my initial reply.
Previous Topic: Creating boundaries in between xml elements
Next Topic: Convert XML data as blob image
Goto Forum:
  


Current Time: Thu Apr 25 08:43:32 CDT 2024