Count of characters in a string

Hi all,
Is there any way to find the repeating characters in the string like 'L' in the example Hello ..
Thanks in advance,
Nalla !
Message was edited by: Nalla
Nalla (Nallasivam)

test@ORA10G>
test@ORA10G> with t as (
  2    select 'hello' as str from dual union all
  3    select 'abracadabra' from dual union all
  4    select 'the quick brown fox jumps over the lazy dog' from dual union all
  5    select 'abcdefghijklmnopqrstuvwxyz' from dual union all
  6    select 'facetious' from dual)
  7  --
  8  select
  9    str
10  from t
11  where (
12    length(str) - length(replace(lower(str),'a')) > 1 or
13    length(str) - length(replace(lower(str),'b')) > 1 or
14    length(str) - length(replace(lower(str),'c')) > 1 or
15    length(str) - length(replace(lower(str),'d')) > 1 or
16    length(str) - length(replace(lower(str),'e')) > 1 or
17    length(str) - length(replace(lower(str),'f')) > 1 or
18    length(str) - length(replace(lower(str),'g')) > 1 or
19    length(str) - length(replace(lower(str),'h')) > 1 or
20    length(str) - length(replace(lower(str),'i')) > 1 or
21    length(str) - length(replace(lower(str),'j')) > 1 or
22    length(str) - length(replace(lower(str),'k')) > 1 or
23    length(str) - length(replace(lower(str),'l')) > 1 or
24    length(str) - length(replace(lower(str),'m')) > 1 or
25    length(str) - length(replace(lower(str),'n')) > 1 or
26    length(str) - length(replace(lower(str),'o')) > 1 or
27    length(str) - length(replace(lower(str),'p')) > 1 or
28    length(str) - length(replace(lower(str),'q')) > 1 or
29    length(str) - length(replace(lower(str),'r')) > 1 or
30    length(str) - length(replace(lower(str),'s')) > 1 or
31    length(str) - length(replace(lower(str),'t')) > 1 or
32    length(str) - length(replace(lower(str),'u')) > 1 or
33    length(str) - length(replace(lower(str),'v')) > 1 or
34    length(str) - length(replace(lower(str),'w')) > 1 or
35    length(str) - length(replace(lower(str),'x')) > 1 or
36    length(str) - length(replace(lower(str),'y')) > 1 or
37    length(str) - length(replace(lower(str),'z')) > 1
38  );
STR
hello
abracadabra
the quick brown fox jumps over the lazy dog
3 rows selected.
test@ORA10G>
test@ORA10G>pratz

Similar Messages

  • Counting Characters in a string

    HI all!
    I am new working with java and i have an application where I have to count specific characters in a string e.g. 'a','.','H','4' and so on! I found an entry in the forum with this script:
    String text = "Hello World!";
    int count = 0;
    for (int x = 0; x < text.length(); x++)
    if (text.charAt(x) == 'l')
    count++;
    This Script count all the 'I', but I could not get CharAt to count different characters at once!
    Is there a way?
    Thx for your help!
    LeBite

    String text = "Hello World!";
    int countl = 0;
    int counto = 0;
    for (int x = 0; x < text.length(); x++)
        if (text.charAt(x) == 'l') countl++;
        if (text.charAt(x) == 'o') counto++;
    [/code[                                                                                                                                                                                                                                                                                                                                                                                                                       

  • How to count number of repeated characters in a String

    I have a String.... 10022002202222.
    I need to know how many 2's are there in the string... here the string contains eight 2's..
    Thanks in advance..

    it is workingYes, but... attention to surprises...
    SQL> var v1 varchar2(1000);
    SQL> exec :v1 := 'How to count the number of occurences of a characters in a string';
    PL/SQL procedure successfully completed.
    SQL> select length(:v1) - length(replace(:v1,'c')) from dual;
    LENGTH(:V1)-LENGTH(REPLACE(:V1,'C'))
                                       6
    SQL> exec :v1 := 'cccccc';
    PL/SQL procedure successfully completed.
    SQL> select length(:v1) - length(replace(:v1,'c')) from dual;
    LENGTH(:V1)-LENGTH(REPLACE(:V1,'C'))
    SQL> select length(:v1) - nvl(length(replace(:v1,'c')),0) from dual;
    LENGTH(:V1)-NVL(LENGTH(REPLACE(:V1,'C')),0)
                                              6
    SQL>

  • 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();

  • How to count number of characters in a string?

    Hi
    I need to display values in a script. but the alignment getting distrubed if it is less than 20 charaters, for exmple material descirption is only displaying 20 characters in script. if it is less than 20 charcters the alignment getting changed.
    please help me ...urgent..
    thanks in advance...

    solution to this problem in script is not to count the characters but to align them based on positions .
    1.
    Use the tab positions  for that paragraph format to display the values in a finite format .
    In this u need to give the position start and position end length and use the same in the script as
    p ,,&itab-f1&
    say my value has to print from position 125mm to 155 mm
    i take one tab position for this paragraph format P and maintain the same in the output.
    here ,, is the tab position .
    See whether it is one character or 20 character it has to behave the same way it should not be misaligned .
    check the tab position for that paragraph format in Tabs ..
    regards,
    vijay.

  • Replace characters in a string

    Hi,
    I need to replace all occurrences of control characters except space,newline,tabs in a string . I can give a replace statement for each of these characters but I want to avoid this by making use of regular expressions. Can anyone help me in this regard.
    I tried using the following replace statements with regular expression, but i am not getting the required results:
    replace all occurrences of REGEX '[[:cntrl:]]' in lv_char with space replacement count lv_count_r.
    ---> this replaces even the spaces
    replace all occurrences of REGEX '[[:cntrl:]][^[:space:]]' in lv_char with space replacement count lv_count_r.
    --> this replaced even some alpha numeric characters
    Thanks and Regards,
    Shankar

    is there anyway to do this without using regular
    expressions.. regular expressions are the last
    solution for me..Remember that you can never really replace the characters of a String. Strings are immutable. Once created they cannot change.

  • Counting the character in a string

    How to find the number of repeated characters in a string
    example- 'RAJA' In this string how many 'A' are there

    A beautiful query posted by a guru in this forum long time ago.
    SQL> set line 1000
    SQL> l
      1     SELECT ename
      2          , Letter_repetition
      3          , COUNT(*)repetition_count
      4     FROM ( SELECT ename
      5                   , Letter_repetition
      6                FROM emp
      7               MODEL
      8                     RETURN UPDATED ROWS
      9                     PARTITION BY (ename)
    10                     DIMENSION BY (0 i)
    11                     MEASURES (ename Letter_repetition)
    12                     ( Letter_repetition[FOR i FROM 1 TO
    13                                         length(Letter_repetition[0])
    14                                         INCREMENT 1] = SUBSTR(Letter_repetition[0],CV(i),1)
    15                     )
    16             )--End of FROM clause
    17      GROUP BY ename
    18          , Letter_repetition
    19*    HAVING COUNT(*) > 1
    SQL> /
    ENAME                               LETTER_REPETITION                   REPETITION_COUNT
    SCOTT                               T                                                  2
    TURNER                              R                                                  2
    ALLEN                               L                                                  2
    MILLER                              L                                                  2
    ADAMS                               A                                                  2
    SQL>

  • Count of characters clipped or corrupted in conventional composition

    In conventional Modern English composition there is more drawing from character codes whereas in classic Early Modern English composition there is more drawing from default glyph codes.
    If Apple Advanced Typography or Microsoft OpenType is used in Apple Pages then between 10% and 40% of the source character string is clipped.
    If Apple Advanced Typography or Microsoft OpenType is used in Apple TextEdit 1.4 for Mac OS X 10.4 and Apple TextEdit 1.5 for Mac OS X 10.5, then some 4% of the source character string is clipped.
    These counts do not include substitution of correct public characters for incorrect private charactoids and incorrect public characters.
    Because more of the drawing must be done in glyph space for Arabic and Indic than for Latin, Greek, Cyrillic and Chinese-Japanese-Korean, one would assume that the scale of the clipping is lowest for the simple scripts and highest for the complex scripts. If someone wants to spend a couple of days counting clipping for Arabic and Indic, it might be worthwhile to know the figures.
    /hh

    Could you explain what you mean by "clipping" and give an example of how you have gone about measuring it?
    Modern imaging models distinguish between content information and imageable appearance, or in technical shorthand terms between code space and data space where the transform between code space and data space is evaluatable (: there are alternate stylistic appearances available as rendering intents in the transform) and where data space is almost any data model (: e.g. prescaled bitmap, TrueType splines, Type 1 splines, indeed any spline programming language for which the system has a scaler / similar data space format flexibility in ICC imaging).
    If content information is mapped to imageable appearance, and if imageable appearance is mapped back to content information, clipping of content information can occur either in the first or in the second step of the transform. In the current context, clipping occurs because PDF does not preserve the source character string complete. The amount of clipping depends on the genre of the copy (annual report or history thesis with heavy use of tabular lower case numbers, proportional lower case numbers, superiors numbers, inferior numbers, small upper case, and lower case ligatures) and on how much of the GLYF Glyph table is drawn off the CMAP Character Map versus how much is drawn off the MORX Metamorphosis Extended or GSUB Glyph Substitution tables which is where clipping occurs since there may be no cross-font glyph identifiers for a PDF consumer to synthesise the source character string from.
    Currently, the system supposedly uses cross-font glyph identifiers for CFF-housed SFNT and the CMAP for TTF-housed SFNT. Driver-level Unicode imaging works like driver-level ICC imaging, which has been much discussed. Basically, in driver-level Unicode imaging the tags of the tagged SFNT file format are stripped and the CFF font program dictionary (a font within a font) is decompressed into Type 1 and streamed into the PostScript language page description program which leaves only the PostScript name space (PostScript is deliberaty designed not to use a coded character set). If the data space is not CFF but TTF, then either the splines are converted to Type 1 (up to and including OS X 10.3) or a Type42 font is generated where it is legal among other things to strip the POST PostScript glyph name table.
    With regard to the calculation method, it is basic. Download and install the Word Counter widget from SuperMagnus Software, available through the Download section of Apple's web site (for whatever reason the Word Counter applet does not appear as reliable). Set the Word Counter widget to exclude word spaces since PDF is winging word spaces anyway (they are synthesised). Input a source character string and count the characters it contains. Compose the source character string with Use Ligatures enabled (whether in Pages or Word 2008 or in TextEdit), use the Typography Palette (not for Word, though) for additional local and manual line layout that cannot be accomplished globally and automatically, save to PDF 1.3, attempt to recover the source character string using e.g. Apple Preview, copy into TextEdit to strip the formatting, copy the character string stripped of formatting into the Word Counter widget, calculate the difference, divide the source number with the difference, multiply by 100, and you have the percentage of clipped characters not counting incorrect public characters and incorrect private charactoids added by the PDF decomposition.
    For example, for a passage from Shlomo Perets' discussion of defect decomposition in the Adobe OpenType Guide published in 2002 see http://www.planetpdf.com/enterprise/article.asp?ContentID=6521 and the following count :
    3. HTML Composition in CMAP Character Map Table of Microsoft Georgia
    copy 12pt on 14pt
    To see potential problems with products that support advanced typography features, such as ligatures, small caps and old-style numerals, see the Adobe OpenType User Guide, authored with Adobe InDesign and exported directly to PDF. "2002" is present in the first page below the title—but cannot be located as since old-style figures are used. The SFNT acronym present in the first paragraph in page 2 cannot be located, as it uses small-caps. "Microsoft" is present 5 times in this document—but none of the instances can be located due to the use of ligatures (ft in this case). Even the word "This" in the opening paragraph in page 2 (line before last) cannot be located due to the use of ligatures. The more common fi, fl, ffi ligatures are searchable in the case of this document, but this is not the case in other documents using these ligatures (this depends on the applications used to author/create the PDF). While these OpenType features result in a superior typography, they should be avoided in online documents, until Acrobat Find and Search functions are enhanced to support the additional characters.
    Shlomo Perets, PDF Best Practices 5: Acrobat Find & Search, PlanetPDF: 22 April 2002
    type product
    Adobe Minion Pro, neither ligatures, nor small capitals, nor lower case numbers ('Old Style Figures') are searchable.
    typesetting logic
    Microsoft OpenType logic (12pt Common Ligatures, Small Capitals, Small Capitals From Capitals, Old Style Figures).
    type version
    Type version 2.012; PS 002.000; core 1.0.38; makeotf.lib1.6.6565. System version Apple Mac OS X 10.4.11. Application version Apple Pages 4.0.
    [Count of 1374 correct public characters.]
    3.1. Composition in CMAP Character Map Table and GSUB Glyph Substitution Table of Adobe Minion Pro 2, Apple Pages 4.0, and Apple Mac OS X 10.4.11
    Please see parallel PDF.
    3.2. Copied PDF Decomposition Composed in CMAP Character Map Table of Microsoft Georgia : Clipped 9.8% off Source Character String
    To see potential problems with products that support advanced typography features, such
    as ligatures, small caps and old-style numerals, see the Adobe OpenType User Guide,
    authored with Adobe InDesign and exported directly to . "" is present in the rst
    page below the title—but cannot be located as since old-style gures are used. e
    acronym present in the rst paragraph in page cannot be located, as it uses small-caps.
    "Microso" is present times in this document—but none of the instances can be located
    due to the use of ligatures ( in this case). Even the word "is" in the opening paragraph in
    page (line before last) cannot be located due to the use of ligatures. e more common ,
    , ligatures are searchable in the case of this document, but this is not the case in other
    documents using these ligatures (this depends on the applications used to author/create the
    ). While these OpenType features result in a superior typography, they should be avoided
    in online documents, until Acrobat Find and Search functions are enhanced to support the
    additional characters.
    Shlomo Perets, Best Practices : Acrobat Find & Search, PlanetPDF: April
    Adobe Minion Pro, neither ligatures, nor small capitals, nor lower case numbers ('Old Style
    Figures') are searchable.
    Microso OpenType logic (pt Common Ligatures, Small Capitals, Small Capitals From
    Capitals, Old Style Figures).
    Type version .; .; core ..; makeotf.lib... System version Apple Mac
    OS X ... Application version Apple Pages ..
    [Count of 1239 characters, including incorrect public characters and incorrect private charactoids.]

  • Specify characters in a string

    I'm a beginner at Java.
    I need to create a program that will validate only binary characters in a string and count the number of 0s in the string. For some reason I keep getting an error message. For the life of me, I can't figure it out.
    char a = '1';
    char b = '0';
    int hmo;
    int totalzeroes=0;
    String input = JOptionPane.showInputDialog(null, "Please Enter a Binary Number");
    for (hmo=0; hmo<input.charAt(hmo);hmo++)
    System.out.println(input.charAt(hmo));
    totalzeroes++;
    OUTPUT:
    Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range:
         at java.lang.String.charAt(Unknown Source)
         at cop.main(cop.java:19)

    ...hmo<input.charAt(hmo)...You have to loop up to input.length(), not to the value of the character at certain position.
    Mike

  • Specify Valid Characters in a String

    I'm a beginner at Java.
    I need to create a program that will validate only binary characters in a string and count the number of 0s in the string. For some reason I keep getting an error message. For the life of me, I can't figure it out.
    char a = '1';
    char b = '0';
    int hmo;
    int totalzeroes=0;
    String input = JOptionPane.showInputDialog(null, "Please Enter a Binary Number");
    for (hmo=0; hmo<input.charAt(hmo);hmo++)
    System.out.println(input.charAt(hmo));
    totalzeroes++;
    OUTPUT:
    Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range:
    at java.lang.String.charAt(Unknown Source)
    at cop.main(cop.java:19)>

    Just a suggestion.. for this kind of stuff you should probably use regular expressions.. You can easily validate that a string contains only 0 and 1 with something like this:
    public boolean validate(String s)
         String PATTERN = "[01]+";
         Pattern pattern = Pattern.compile(PATTERN, Pattern.CANON_EQ);
         Matcher matcher = pattern.matcher(s);
         if (matcher.matches())
              return true;
         else
              return false;
    Here, you can easily change the PATTERN if you want the string to match something else..

  • How to search special characters in a string

    Hi all,
    I want to search special characters in all string columns and all rows in the table.
    The table has about 5 string columns and about 5.000.000 rows. For each row and column, I have to search entries, which included special characters like ", !, ? or something else (f.ex. "Mama?Mia" or "!!!Hotel out of order!!!"). The problem, the character could stand at each position in the string.
    What's the best and most performance possibility to search such entries?? Is it possibility only by SQL; is there a special function for this?? Or must I use PL/SQL.
    Thanks for helping
    Dana

    HTH
    Laurent Schneider
    OCM DBA
    SQL> select * from z;
    S
    Mama?Mia
    a b c
    123
    SQL> select * from z where translate(s,'~ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz1234567890','~') is not null;
    S
    Mama?Mia
    SQL> select * from z where regexp_like(s, '[^[:alnum:][:space:]]');
    S
    Mama?Mia

  • How do I drop the last 3 characters in a string?

    Hello.  I'm trying to find a way to drop the last 3 characters in a string.  The length varies because it is a last name field.  The problem is that when a customer has a suffix on their name, III for example, it is appended to the last name all in the last name field.  If I use the ProperCase function, I end up with "Smith Iii".  How can I tell it to drop the last 3 characters?  I'll then append an UpperCase edition of the last 3 characters to that.  Thank you!

    Use the instring and right string functions then UpperCase

  • How to find out if there are repeated characters in a string

    hey guys
    well i kinda have a little problem figuring out how to find out
    if there are repeated characters in a string.
    if anyone can help, would appreciate it.
    thanks
    milos

    Try using the StringTokenizer class. if u already know which character to trace. this could do the job.
    eg. String str = "here and there its everywhere";
    StringTokenizer st = new StringTokenizer(str, "e");
    int rep = st.countTokens();

  • Removing non english characters from my string input source

    Guys,
    I have problem where I need to remove all non english (Latin) characters from a string, what should be the right API to do this?
    One I'm using right now is:
    s.replaceAll("[^\\x00-\\x7F]", "");//s is a string having chinese characters.
    I'm looking for a standard Solution for such problems, where we deal with multiple lingual characters.
    TIA
    Nitin

    Nitin_tiwari wrote:
    I have a string which has Chinese as well as Japanese characters, and I only want to remove only Chinese characters.
    What's the best way to go about it?Oh, I see!
    Well, the problem here is that Strings don't have any information on the language. What you can get out of a String (provided you have the necessary data from the Unicode standard) is the script that is used.
    A script can be used for multiple languages (for example English and German use mostly the same script, even if there are a few characters that are only used in German).
    A language can use multiple scripts (for example Japanese uses Kanji, Hiragana and Katakana).
    And if I remember correctly, then Japanese and Chinese texts share some characters on the Unicode plane (I might be wrong, 'though, since I speak/write neither of those languages).
    These two facts make these kinds of detections hard to do. In some cases they are easy (separating latin-script texts from anything else) in others it may be much tougher or even impossible (Chinese/Japanese).

  • Need help in replacing special characters in a string

    Hi,
    please let me know the best way to replace all the special characters in a string with space.
    other than alphabets and numbers
    with regards.
    sumanth.

    please let me know the best way to replace all the special characters in a string with space.
    other than alphabets and numbers
    >
    Sumanth Nag Kristam wrote:
    > actually i need to replace hexa decimal char 0X1A in a string.... that is 'substitue' as per the chart
    > any pointers....
    >
    > chk the link for the ASCII codes
    > http://www.techonthenet.com/ascii/chart.php
    But in Hexa decimal value there is no special characters?

Maybe you are looking for

  • Adobe Suite will not run with most recent Java after I have installed Yosemite

    I have updated to Yosemite for my Mac, when trying to open Adobe Photoshop it prompted me to install Java 6, which I installed, then Java said to update to 8, which I did. My photoshop and other adobe suite programs still will not open (except Bridge

  • MacBook Pro burn DVD failed even after installing Leopard 10.5.2

    Ever since upgrading from Tiger to Leopard my 17in MacBook Pro has failed to burn DVDs. It managed to burn a couple discs after the upgrade, but soon proceeded to give various error messages whenever I have attempted to burn a DVD. The most common er

  • Line item txt on sales order

    I changed my line item type to text on the sales order.  Now I want to add that text field to print on my order, but I can't find where it is stored.  I have checked the RDR1, INV10 tables, but the text I typed isn't there.  Anyone know what tables h

  • Need to find 4.1 for 2nd gen Touch

    I'm posting this for a friend who is stuck on Tiger and cannot upgrade to iTunes 10, which apparently is required to run IOS 4.2. For whatever reason, she had not upgraded her IOS since version 2.something. Now the only option available to her when s

  • My phone wont sync to my computer it says mobile account isn't active?

    i have a new computer ,windows 7 and my iphone wont sync with itunes. It says mobile device is not active? help please.