Need help in finding the position of a SubString in a String

Hi All,
I have a VARCHAR2 column in my table which has data similar to '152-425-3265-8-5623-45'.
I want to find the position of the numbers in the column.
For example:
If i give 8 - query should return me 4.
If i give 425 - query should return me 2.
The numbers are delimited with '-' value.
Please help.
Thanks in advance.
Edited by: 868171 on Jun 24, 2011 4:33 AM
Edited by: 868171 on Jun 24, 2011 4:34 AM

do you know the max number of dashes?
if so
with t as (select  '152-425-3265-8-5623-45' code, '425' num from dual union
               select  '152-425-3265-8-5623-45' code, '8' num from dual)
select code, num, case num when  regexp_substr( code,'[^\-]+',1,1) then '1'
               when  regexp_substr( code,'[^\-]+',1,2)  then '2'
               when  regexp_substr( code,'[^\-]+',1,3) then '3'
               when  regexp_substr( code,'[^\-]+',1,4)  then '4'
               when  regexp_substr( code,'[^\-]+',1,5) then '5'
               when  regexp_substr( code,'[^\-]+',1,6)  then '6'
               else 'not found' end result
from t
CODE     NUM     RESULT
152-425-3265-8-5623-45     425     2
152-425-3265-8-5623-45     8     4or if you have 11g you can use regexp_count
with t as (select  '152-425-3265-8-5623-45' code, '425' num from dual union
               select  '152-425-3265-8-5623-45' code, '8' num from dual)
select code, num, regexp_count(regexp_substr(code,'^.*'||num||'.'),'-')
from tEdited by: pollywog on Jun 24, 2011 7:55 AM

Similar Messages

  • Need help in finding the number of occurrences of a pattern.

    Hi All,
    I need help in finding the number of occurrences of a pattern in a table's column's data.
    Consider sample data - one row's column from a table:
    "S-S-S-A-S-S-P-S-S-B-S-A-P-S-S-C"
    My requirement is:
    I should get the count of S's which are immediately preceded by A or P.
    for the above data i should get count as 3+2+1=6 (S-S-S-A, S-S-P, S-A)
    The pattern data is stored as VARCHAR2 type.
    Thanks in advance,
    Girish G
    Edited by: Girish G on Jul 21, 2011 11:22 PM

    I am sure there exists a better way then this one:
    SQL> with dt as
      2  (select 'S-S-S-A-S-S-P-S-S-B-S-A-P-S-S-C' str from dual)
      3  SELECT SUM(Regexp_count(Regexp_substr(str, '(S\-?)+(A|P)+', 1,
      4                                     Regexp_count(str, '(S\-?)+(A|P)+') - (
      5                                                  LEVEL - 1 )), 'S')) len
      6  FROM   dt
      7  CONNECT BY LEVEL <= Regexp_count(str, '(S\-?)+(A|P)+')
      8  /
           LEN
             6

  • I need help to find the serial number for Photoshop Elements 11

    Hi! I need help to find the serial number for Photoshop Elements 11 I downloaded last year on Apple Application Store.. I have been using photoshop on mac for over a year and now need the serial number to be able to use it on macbook. I looked up Adobe's website for help but found none and noone to ask for support.. Any ideas how I can get the serial number using the App Sore bill I have?

    Please post Photoshop Elements related queries over at
    http://forums.adobe.com/community/photoshop_elements

  • Need help to find the "leading point size"

    Hi,
    I need help to find the "leading point size".
    Any para style leading is more than 2 points of my font size, I need the alert message "Its more than 2 points for your font size". For instance my para font size is 10 here my leading should be 12 points rather than its 14 points, I need the alert message.
    Is this possible by script?
    by
    hasvi

    Hi Hasvi,
    Try this.
    var doc = app.activeDocument;
    var texts = doc.stories.everyItem().textStyleRanges.everyItem().getElements();
    var pstyle = "Following paragraph styles have more leadings:\r\r";
    for(var i=0;i<texts.length;i++)
        var ps = texts[i].pointSize;
        if(texts[i].leading > ps + 2)
            pstyle += texts[i].appliedParagraphStyle.name;
    alert(pstyle)
    If it is correct than mark the answer as correct and don't mark your question as correct answer.
    Regards,
    Chinna

  • Need help to find the correct .MIB-file

    Hi.
    We are using some Nexus 7009 chassis on my work and a program called "SNMPc" that receives traps from our Nexus devices.
    The program do not have the new Nexus 7000 MIBs so we are only getting "pure text" from Nexus.
    We need to download the right type of MIB file so we can get a better understanding of what is happening on the Nexus.
    We can ONLY use ".mib" extensions but Cisco currently only offering ".traps", ".my" and ".oid" files what I can find.
    This is an example message we get:
    ciscoMgmt.706.0.1 [1] ifName.437260288 (DisplayString): Ethernet3/2 [2] ciscoMgmt.706.1.1.0 (Integer): 5 [3] ciscoMgmt.706.1.2.0 (Integer): 5 [4] ciscoMgmt.706.1.3.0 (Integer): 5 [5] ciscoMgmt.706.1.4.0 (Integer): 5 [6] ciscoMgmt.706.1.5.0 (Integer): 5 [7] ciscoMgmt.706.1.6.0 (Integer): 5 [8] ciscoMgmt.706.1.7.0 (Integer): 5 [9] ciscoMgmt.706.1.8.0 (Integer): 4 [10] ciscoMgmt.706.1.9.0 (Integer): 5 [11] ciscoMgmt.706.1.10.0 (Integer): 5 [12] ciscoMgmt.706.1.11.0 (Integer): 5 [13] snmpTrapEnterprise.0 (ObjectID): ciscoMgmt.706
    We can see that the trap name is: 1.3.6.1.4.1.56.12.1.1.0.1
    Can someone help me get the right MIB?

    Silly question but have your tried changing the file extension of the .my files to .mib  ?  I typically have to do something like that for net-snmp with Cisco MIB files...
    - Be sure to rate all helpful posts

  • Need Help in finding the Menu Path's for the below topics

    Hi,
    Where can i get the menu paths for the below topics in SAP syste. I have searched in the system,But couldnot find the Menu Path's for the below topics.Kindly help me in finding the configuration Path for the below...
    1)Public tendering process
    2)Grants Management
    3)Tax & Revenue management
    4)Public sector accounting --> Budget formulation, preparation, execution & Monitoring.
    Thanks
    Rajitha M

    Hi,
    Check for the relevant path in IMG in Public Sector Management.  The prerequisites being configuration of Financial accounting
    sub modules.
    Best Regards,
    Sadashivan

  • Need help in finding the root cause the error 'Could not find function:'

    Hi fokls,
    In my workflow notification , when I click on the notification to process it , it says ' 'Could not find function:' error.
    I found the this message is coming out from the Fnd_new_messages table from the message_name 'FND_FUNCTION_NOT_FOUND'.
    Here are my questions ...
    1. FND_FUNCTION_NOT_FOUND - Is it a oracle Seeded message ?
    2. If so the error I am getting is a oracle product Bug ?
    And In between , I am getting this error for few transaction only. ( out of 100 , i am getting this error at the rate of 5 per 100 ... or less)
    3 .If its a oracle product bug then , how is 95 out of 100 transaction are succssfully wokring ?
    4. If is a custom bug , how it os not though for some other 95 transaction ?
    5. Can I expect it as Data issue ? If so what kind of data issue.
    Folks , any kind of info will be really , realy helpful for me ... please let me know your inputs for me.
    Thansk to all in advance
    Raghu

    In the error message 'Could not find function:' after colon what function name it is giving.
    'FND_FUNCTION_NOT_FOUND' is a seeded message only.
    As you are saying the error was throwing only for 5% or less notifications, is the error throwing for same kind of notifications? I mean the item type and message are same for these erroneous notifications?
    It can be that some function in particular type of workflow is error-ed out does not exists, when responding to those kind of notifications it might be throwing error.
    Please check that.
    Edited by: sarojak on Nov 12, 2010 6:16 AM

  • I need help on finding the right video camera

    I am a high school student and I make short films. I use final cut express. I'm getting ready to do a short film for a film festival. I really want a new video camera but i don't know what to get. The price range is under 2000. If anyone knows what would be the best i would really appreciate the input.
    Thanks

    At the moment i have been using a Sony GC1 for small stuff but other videos i use a panasonic, im not sure of the name i don't have it with me.
    The quality is really bad on the sony mainly because its just a net sharing cam and the panasonic is not mine so i dont have full access.
    I really want something with good quality, 24p, can work with my macbook, just an overall good camera that will endure a lot of use.

  • Bad game performance: "Tibia" - need help to find the error

    hi
    im playing a game called tibia (www.tibia.com) for a long time, back on windows i had no problems with the programm(except that windows itself crashed sometimes while playing ;P).
    since some time they made an linux client again and i tryed it on my pc, running arch with all updates.
    my problem is that sometimes when (probably to much) pictures like garbage and player are shown on the screen(its an 2d mud inspired by ultima) i get performence issues, the program is freezing 2 seconds before i can view another level, just to say an example.
    via "top" i watched what kicks in that uses my cpu so much and it is X.
    ok, now i dont realy know where this post belongs, more here or into newbie's corner, but:
    as i said before i have every possible update for arch and the installed programms.
    i got an geforce fx 5200 with the newest driver(manualy installed because the installer via pacman whont have the new driver because of an outdatet kernel, atleast that was what i remember).
    my problem now is that i just dont know where the error is.
    i know of people, using the same client as i that dont have that issues.
    i already bugged the support forums but as far as i saw they dont realy like arch user, atleast they dont answer to their questions. ;P
    i whant to know if MAYBE someone is here who plays tibia and can tell me that he got the same problems like i do or not.
    or you could give me hints what i could try to solve this problem.
    to write it in one short line:
    the problem is that the process "X" sometimes kicks in, using 100% of the cpu, this happens only while playing "tibia"
    thank you

    Look at Steps #4, #6, #9 and #12.
    http://helpx.adobe.com/dreamweaver/kb/troubleshoot-javascript-errors-dreamweaver-cs4.html
    Nancy O.

  • Need help to find the table which stores the infomation listed below

    Hi,
       I am working on Archiving work for archiving the data under the tcode SOST.I searching the table which stores the email document content but I am having difficulty to get the table..Could any one provide some input on this.
    Thanks.
    ~Donny

    I believe it is stored in table SOFFCONT1

  • Finding the position of an integer in a string

    I haven't done much Java programming for the past 3 months, but I'm trying to get back into it now, but I'm having some trouble. I'm trying to break up a string of integers, to store each individual integer in an array.
    So, if I had something like 132412344, a for loop would put them all into separate arrays.
    I know that there is a charAt() function, but is there something like that for integers?

    Do you know whether every single character in the string is an integer?
    If it is, then toCharArray will get you the array. Then you could loop through it to parse each character into an int. You can use Character.digit to do that.
    I doubt that there's any method that automatically splits a string and returns the integers represented by the characters in a string. It seems like too specialized a method. But I could be wrong.

  • Need help to find photo's on my backup drive,since installing Mountain Lion cannot find where they are stored.The backups after ML install are greyed out except in Applications, MyFiles and Devices really welcome a hand with this please.

    I need help to find my photo's please (2500) on my backup drive.Lost them after doing a clean install of Mountan Lion I have tried to find them but had no luck.  I use Time Machine with a 1TB Western Digital usb drive. Thanking anyone in anticipation of a solution.

    -Reece,
    We only have 1 single domain, 1 domain forest, no subdomains, only alias. I had replied to the other post as well. But I am happy to paste it here in case anyone want to read it.
    So, after a few months of testing, capture and sending logs back and forth to Apple Engineers, we found out there is a setting in AD, under User Account that prevent us to log into AD from Mountain Lion. If you would go to your AD server, open up a user account properties, then go to Account tab, the "Do not require Kerberos preauthentication" option is checked. As soon as I uncheck that option, immediately I was able to log into AD on the Mac client. Apple engineers copied all my AD settings and setup a test environment on their end and match exact mine AD environment. They was able to reproduce this issue.
    The bad part about this is... our environment required the "Do not require Kerberos preauthentication" is checked in AD, in order for our users to login into some of our Unix and Linux services. Which mean that it is impossible for us to remove that check mark because most, if not all of them some way or another require to login into applications that run on Unix and Linux. Apple is working to see if they can come up with a fix. Apparently, no one has report this issue except us. I believe most of you out there don't have that check mark checked in your environment... Anyone out there have any suggestion to by pass or have a work around for this?

  • Hi.I need help.my iphone was Stolen .how can I get back my iphone. Serial No.DX*****PMW.could you help me find my iphone.thank you very much.could you send me the ICCID number to help me find the iphone

    Hi.I need help.my iphone was Stolen .how can I get back my iphone.  Serial No.DX******PMW.could you help me find my iphone.thank you very much.could you send me the ICCID number to help me find the iphone.if you can help me.
    <Personal Information Edited by Host>
                                                                                                                                                                   Sincerely a Chinese girl really need your help

    Sorry we are all users on this User  Community No Apple Staff
    Read this .
    http://support.apple.com/kb/HT2526
    Apple do not and cannot assist in finding stolen property ,that is the responsility of your Police

  • I need help in finding all the new fontsin iPad 2 using iOS  5

    I need help in finding all the new fonts in ipad 2 using ios 5

    You cannot change the email font. You can make it bold, italics and underline the type, but Helvetica is your only choice in the mail app.
    In the notes app you have 3 choice Noteworthy, Helvetica and Marker Felt. The font can be changed in Settings>Notes>Font.
    You can only use fonts that are built into the app that you are using at the time. You cannot pick and choose fonts from a list of all of the fonts that may be on the iPad but only from the list of fonts that the app allows.

  • Finding the position of the end of a line in a JTextPane

    I'm trying to make a JTextPane which expands horizontally if the text being typed in it reaches the right hand edge. To do this I need to know the position in the Document of the end of the current line.
    I've managed to write a method which expands the JTextPane vertically using getEndPosition() in AbstractDocument.
    There is an endLineAction in the DefaultEditorKit which moves the Caret to the end of the line but I don't want to move the Caret, just find the position of the end of the line. I did have a method before which moved the Caret to the end of the line, stored the position and moved it back but that wasn't suitable.
    I suspected the answer was to do with the View but I can't figure out how the View relates to the JTextPane or Document.
    Can anyone help?

    Well, personally I don't think its a good idea to keep changing the size of the text pane as text is being typed and I doubt the solution will be as easy as you think.
    As you type the text will automatically wrap so it will be a little late trying to change the width after the text has wrapped, which means you would need to increase the width "before" text is typed. But then you have another problem because you don't know how much to increase the width by since a single character could be typed or a string of text could be pasted into the text area (people always forget about pasting when doing stuff like this).
    Also if text is removed you would need to iterate through all the line to find the longest line and reset the width.
    Anyway the only way to know the width would be to play with the modelToView() method. If you want to find the end of the current line then you can use the Element.
    Check out my [Text Utilities|http://www.camick.com/java/blog.html?name=text-utilities] class which might give you some ideas on how to use the Element class and modelToView() method.
    which has example of using the above Class and method that might give you some ideas.

Maybe you are looking for