Home » SQL & PL/SQL » SQL & PL/SQL » Striping characters (merged) (SQL)
icon5.gif  Striping characters (merged) [message #425630] Sun, 11 October 2009 00:06 Go to next message
ANANTA
Messages: 2
Registered: October 2009
Location: vfd
Junior Member
Hi,
A field contains value in this format : xxxx\yyyyy\sss\zzxz\zxcdds
I want to strip characters before second '\' and also after the third '\' . So in the end I should see only 'sss'.

Can any one please help?
Re: Striping characters [message #425632 is a reply to message #425630] Sun, 11 October 2009 00:13 Go to previous messageGo to next message
BlackSwan
Messages: 24908
Registered: January 2009
Senior Member
Post Operating System (OS) name & version for DB server system.
Post results of SELECT * from v$version.

You need to help us by following the Posting Guidelines as stated below.
http://www.orafaq.com/forum/t/88153/0/
Go to the URL above click the link "Posting Guidelines"
Go to the section labeled "Practice" & do as directed.

DO not cross/multi-post




Post DDL for tables.
Post DML for test data.

Post expected/desired results
Post detailed explanation how & why test data gets transformed into expected/desired results.

[Updated on: Sun, 11 October 2009 00:16]

Report message to a moderator

Re: Striping characters (merged) [message #425633 is a reply to message #425630] Sun, 11 October 2009 01:10 Go to previous messageGo to next message
Michel Cadot
Messages: 63806
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Use INSTR to find the \ and SUBSTR to get the substring.

Regards
Michel

[Updated on: Sun, 11 October 2009 01:11]

Report message to a moderator

Re: Striping characters [message #425674 is a reply to message #425632] Sun, 11 October 2009 09:30 Go to previous messageGo to next message
ANANTA
Messages: 2
Registered: October 2009
Location: vfd
Junior Member
Could you pls explain it?
Re: Striping characters (merged) [message #425675 is a reply to message #425630] Sun, 11 October 2009 09:40 Go to previous messageGo to next message
BlackSwan
Messages: 24908
Registered: January 2009
Senior Member
We expect you to do you own homework assignments.

Re: Striping characters [message #425676 is a reply to message #425674] Sun, 11 October 2009 09:52 Go to previous messageGo to next message
Michel Cadot
Messages: 63806
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
ANANTA wrote on Sun, 11 October 2009 16:30
Could you pls explain it?

You have the links to the documentation, study them and post your tries or solution.

Regards
Michel

Re: Striping characters [message #425783 is a reply to message #425674] Mon, 12 October 2009 03:27 Go to previous message
JRowbottom
Messages: 5933
Registered: June 2006
Location: Sunny North Yorkshire, ho...
Senior Member
You can pass a parameter to INSTR telling it which occurrence of the search string you are looking for- in this case, you're looking for the 2nd ocurence.

Once you've got this positino, you use SUBSTR to extract a known number of characters from that position.

If you're on 10g, then you can use Regesp_substr to do this.

[EDITED by LF: fixed INSTR link]

[Updated on: Mon, 12 October 2009 13:38] by Moderator

Report message to a moderator

Previous Topic: subquery
Next Topic: Need help with SQL query (merged)
Goto Forum:
  


Current Time: Tue Sep 27 17:55:55 CDT 2016

Total time taken to generate the page: 0.12201 seconds