Counting no of digits in a string

Hi all,
Could you please help me on below mentioned one
i need count of digits in the given string
str='' my contact number is 1234567890''
i tried like this
select regexp_count( str,\d) from dual;

SQL> var str varchar2(200);
SQL> exec :str :='my contact number is 1234567890';
PL/SQL procedure successfully completed.
select length(ltrim(translate(:str,translate(:str,'0123456789',' '),' '))) cnt from dual;
  CNT
   10
exec :str :='my number is 9945814523 and my brother number is 9918457853,54';
PL/SQL procedure successfully completed.
select length(ltrim(translate(:str,translate(:str,'0123456789',' '),' '))) cnt from dual;
  CNT
   22
Message was edited by: Priyasagi

Similar Messages

  • Count number of characters in a string

    Another one for you experts:
    Is there a way to count the number of "-" in the strings below:
    For instance:
    1133500-1-RTN-629-RHR
    1133541-10-SRTN-F-630-LR
    Should return:
    4
    5
    respectively.
    Any ideas?
    Thanks in advance,
    Zack H.

    stringvar x := '1133541-10-SRTN-F-630-LR';
    stringvar array z := split(x,'-');
    ubound(z)-1;

  • Problem  to access my count in adobe Digital Editions

    Dear,
    I`ve problem to access my count in Adobe Digital Edition, I bought an eBook in pdf format and when try read it, ask me to get in for  my ID and password ind Adobe Digital Editions,  report that there is another user use my licence.
    Thus, I know that I`ve got 6 licence  for Adobe Digital Editions.

    Adobe ID, sign-in, and account help

  • How to count number of words in a string?

    Is it only possible by counting the number of white spaces appearing in the string?

    Of course that also depends upon how accurate you need to be and what the string contains. It is completely possible that there might be a line break which doesn't have a trailing or leading space.
    Like that.
    In that case Flash's representation of the string is likely "...space.\n\nLike that.." In chich case "space.\n\nLike" will be a word.
    Also if you split on space and there are places where there are two spaces in a row you could inflate your number. So somthing that changes newlines (and returns) to spaces, then removes any multiple spaces in a row, and finally does the split/count thing would be more accurate.
    But it all depends upon what you need.

  • Count Of each char in a String(Column)

    Hi,
    I have on column which stores any string.
    I need count of each alphabet, repeated how many times.
    For Ex:
    If a column has value "ORACLE TECHNOLOGY",
    O is repeated 2 times, R occurs 1 time, E is repeated 2 time etc.,
    Please send the SQL Query for the above problem!!!
    Thanks,
    regards,
    Suman Naidu.S

    Or..
    http://forums.oracle.com/forums/thread.jspa?messageID=
    1410941?Nice one Janeesh. I had to laugh though at the number of reponses who were giving PL/SQL answers whilst the OP kept on saying "No, I want a Query" meaning he wanted it just as SQL. Only one person gave a valid answer.
    ;)

  • How to get the first 6 digits and the last 4 digits in a string ?

    Greetings folks.
    A quick question and probably quite simple for a lot of guys out there.
    I have a string that could be anywhere between 15 to 20 characters ( Not a fixed length )
    I want it to be split into 3 segments.
    Segment 1 : 123456 ( 6 digits )
    Segment 2 : Everything else in the string from where Segment 1 ends (+1) and Segment 3 begins (-1).
    Segment 3 : 1234 ( 4 digits )Any help is appreciated !
    Thanks

    Hi,
    Try:
    SQL> with t as (
      2  select 2357248357953456217244 col from dual union all
      3  select 3490872049578204934532 col from dual
      4  )
      5  select substr(col, 1, 6) part1
      6  ,      substr(col, 7, length(col)-10 ) part2
      7  ,      substr(col, -4, length(col)) part3
      8  from  t;
    PART1  PART2                              PART
    235724 835795345621                       7244
    349087 204957820493                       4532
    2 rows selected.
    edit
    Hmz, I type way to slow in comparison to Alex and Blu ;)
    edit2
    Besides typing to slow, I also type too much:
      7  ,      substr(col, -4, length(col)) part3This is indeed enough:
      7  ,      substr(col, -4) part3Thanks for the reminder ;)
    Edited by: hoek on Jul 16, 2009 4:54 PM
    Edited by: hoek on Jul 16, 2009 4:57 PM

  • How to count no. of tokens in a string?

    hello everybody?
    I am using StringToknizer to read a csv file line by line.
    My problem is:
    i want to know how many tokens are there in a particular row. How to count it at a streatch?
    i am using
    <%
    if (st.hasMoreTokens())
         a3=st.nextToken().trim();
    %>i thought of using String.split(), but, i don't know how to use it?(what class to import)
    Anyguidence will be appreciated
    Thanks for your time.
    Regards,
    Ashvini

    StringTokenizer will do it for you!
    int numberOfTokens = st.countTokens();m

  • Method to count number of characters in a string?

    hi.
    i'm trying to write some script that will count the number of characters in a string passed into a constructor and then compare it against another value to check whether the string passed in is valid.
    something like this
    public class Stringcheck
    public static int maxStringLength;
    public static double minSize;
    public static boolean testStringLength(String x)
    // Insert method for counting number of chars in String x and name as 'int numberOfChars
    if(number of Chars <= maxStringLength )
    return true;
    else
    return false;
    can someone help me with writing this script.
    Thanks
    Richard.

    ummm, you dont need anything fancy. try:
    String test = "this is the test string";
    int length = test.length();

  • Use counter to control digital IO?

    I'm new to Labview and using a PCI 6010.  I'd like to generate two finite digital pulse trains such that one is in the 'on' position while the other is in the 'off position' and vice versa.  The pulse trains will have the same frequency and opposite duty cycles (ie if duty cycle is 0.2 the other is 0.8).
    I've gotten a single pulse train using a counter output and the example Dig Pulse Train-Finite vi, but am having trouble getting the second pulse train.
    Things I've tried unsuccessfully:
    1. Use DAQ Assistant to generate two pulse trains using two counter outputs, while delaying one train so that they're inverted.
    2. Use two counter outputs where one displays the inverse of the other
    3. Use one counter to generate pulse, invert pulse, and use a digital output to send inverted pulse
    4. Simulate square wave, send to one digital output, while sending the inverse square wave to another digital output.
    I would assume that some of these methods are simply not possible, but I'm not sure which to pursue further.  I would appreciate any advice on the simplest strategy to achieve my desired output.  Thanks.

    Hello jman1,
    Since this was a duplicate post, please refer to the original issue/post included below. For the purposes of making the forums/solutions searchable for the community, please reserve creating new form posts for new issues. Thank you
    1. Synchronized finite digital pulse trains: http://forums.ni.com/ni/board/message?board.id=170&message.id=480738#M480738
    Regards,
    Ali M
    Applications Engineer
    National Instruments 
    Message Edited by Ali M on 03-09-2010 07:43 PM
    Message Edited by Ali M on 03-09-2010 07:44 PM

  • Arming a counter polling a digital line

    For arming a counter, a start trigger on the STC counter can be roughly emulated by polling a digital line and arming the counter once a high digital pulse is sensed. How can i do that?
    I'm using a PCI-MIO-16E-4

    Daniel,
    You did not mention which programming environment you are using, so I will describe the structure in LabVIEW (no matter which language you are using, this should give you the general idea).
    1. Configure your DIO port with DIO Port Config.vi.
    2. Configure your counter operation (Counter Group Config.vi, etc.).
    3. In a while loop, call DIO Port Read.vi.
    4. Monitor the bit corresponding to your trigger line. When this bit goes high, stop the while loop.
    5. Immediately after the while loop, call Counter Control.vi to arm your counter.
    This should be the basic structure of your program. Good luck with your application.
    Spencer S.

  • How do count the character in the given string?

    hi all,
    i have astring like 'AAAARAMARAOAAA'.
    i want count how many 'A's in this string using sql statement.

    Is that a joke? You asked that in a previous thread of yours: how do count how many 'A' s in this string using sql stmt?.
    C.

  • Counter as a digital Trigger

    Hi,
    I wrote a programm for a PCI 6289. It realises a triggered analog voltage in- and output with the internal counter. With this PCIcard I can use the trigger directly with the PFI12 pin and everything is fine.
    Now, I transfered it to a PC with a PCI-MIO16E1 (6070E) card.With this card the Counter isn`t linked to PFI. My question is: What can I do to bring the card to use the counter correctly. I tried already with "connect terminals" but I`m not able to select the counter in that configuration. Has someone a good idea?
    Greeting Daniela 

    Hi Daniela,
    I think the easiest way ist to wire it directly from counter out to one PFI, isn't it?
    Furthermore you can do it this way maybe:
    Internally Routing Counter Signals in LabVIEW
    http://digital.ni.com/public.nsf/allkb/8A85E97855E​DADC98625730C00065F58?OpenDocument
    regards
    Tobias

  • PCI 6601 Counter stops when digital channel operated

    This is a problem being re-visted from last year after thinking I had found a solution.
    Basically I have set two while loops up.
    Each While loop has a counter channel running in it, Ctr0 and Ctr3 respectivly.
    When the program is run the two counter channels generate a waveform as expected.
    I then have added into each While loop Digital output channels that provide logic for Direction and Enable.
    If the program is now run Ctr0 outputs as expected but Ctr3 remains off.
    I then put the digital WRITE vi's into case statements, put the case to false and started the program.
    Both counters outputted waveforms.
    Turned one of the case statements on and Ctr3 stops. It did not matter which case statement was turned off, Ctr3 always stops.
    Tried changing counters to Ctr1 and Ctr2 - Same result one counter stops
    Changed the 6601 for a 6602 and got similar results.
    I have attached vi in version 8.6
    Jack
    Labview Version 8.5
    Labview Version 8.6
    Labview Version 2013
    Attachments:
    Run 2 Counter Chg Freq 2.vi ‏28 KB

    Vi with digital channels added.
    Jack
    Labview Version 8.5
    Labview Version 8.6
    Labview Version 2013
    Attachments:
    Run 2 Counter Chg Freq 3.vi ‏35 KB

  • Help: how to extract digits from a string?

    Hi,
    I am trying to make a formatted phone number report. The field is VARCHAR2(20). There might be some sort of irregularities. What I need to do are in two steps:
    1. extract all digits in order;
    2. format the output as (xxx) xxx-xxxx
    Any suggestions?
    Thank you in advance.
    Jimmy

    This might be of some use to clean up the phone numbers.
    drop   table phone_numbers;
    create table phone_numbers
    (phone      varchar2(20));
    insert into phone_numbers(phone) values ('(111)-555-1212');
    insert into phone_numbers(phone) values (' 111 555 1212');
    insert into phone_numbers(phone) values ('#555-1212');
    insert into phone_numbers(phone) values ('Bob @ 555-1212');
    commit;
    select phone, translate(phone,'0123456789()-.@#* ','0123456789') edited_phone
    from   phone_numbers;
    PHONE                EDITED_PHONE
    (111)-555-1212       1115551212
    111 555 1212        1115551212
    #555-1212            5551212
    Bob @ 555-1212       Bob5551212You can see by the last example that the search string in the translate function should contain every character you can type on a keyboard.

  • Fastest way to count the number of occurences of string in file

    I have an application that will process a number of records in a plain text file, and the processing takes a long time. Therefore, I'd like to first calculate the number of records in the file so that I can display a progress dialog to the user (e.g. " 1234 out of 5678 records processed"). The records are separated by the string "//" followed by a newline, so all I need to do to get the number of records is to count the number of times that '//' occurs in the file. What's the quickest way to do this? On a test file of ~1.5 Gb with ~500 000 records, grep manages under 5 seconds, whereas a naive Java approach:
    BufferedReader bout = new BufferedReader (new FileReader (sourcefile));
                   String ffline = null;
                   int lcnt = 0;
                   int searchCount = 0;
                   while ((ffline = bout.readLine()) != null) {
                        lcnt++;
                        for(int searchIndex=0;searchIndex<ffline.length();) {
                             int index=ffline.indexOf(searchFor,searchIndex);
                             if(index!=-1) {
                                  //System.out.println("Line number " + lcnt);
                                  searchCount++;
                                  searchIndex+=index+searchLength;
                             } else {
                                  break;
                   }takes about 10 times as long:
    martin@martin-laptop:~$ time grep -c '//' Desktop/moresequences.gb
    544064
    real     0m4.449s
    user     0m3.880s
    sys     0m0.544s
    martin@martin-laptop:~$ time java WordCounter Desktop/moresequences.gb
    SearchCount = 544064
    real     0m42.719s
    user     0m40.843s
    sys     0m1.232sI suspect that dealing with the file as a whole, rather than line-by-line, might be quicker, based on previous experience with Perl.

    Reading lines is very slow. If your file has single byte character encoding then use something like the KMP algorithm on an BufferedInputStream to find the byte sequence of "//\n".getBytes(). If the file has a multi-byte encoding then use the KMP algorithm on a BufferedReader to find the chars "//\n".getCharacters() .
    The basis for this can be found in reply #12 of http://forum.java.sun.com/thread.jspa?threadID=769325&messageID=4386201 .
    Edited by: sabre150 on May 2, 2008 2:10 PM

Maybe you are looking for