Character count in a String

Write a SQL statement to show how many R's in the 'Ram Ratan Sarkar' string.

1. remove all characters from a string except 'x' using regexp_relplace (example: 'ab,xc dx' --> 'xx')
2. remove all characters from a string except 'x' and 'y' using regexp_relplace (example: 'aby,xc dx' --> 'yxx')
SQL>
SQL>
with t as (
  select 'ab,xc dx' as str from dual union all
  select 'an x and few more xxx''s here' from dual union all
  select 'xyz-xyz-xyz-xyz-xyz' from dual)
select
  str,
  regexp_replace(str,'[^x]') as mod_str
from t;
STR                          MOD_STR
ab,xc dx                     xx
an x and few more xxx's here xxxx
xyz-xyz-xyz-xyz-xyz          xxxxx
SQL>
SQL>
with t as (
  select 'aby,xc dx' as str from dual union all
  select 'an x and a y and few more yyyy''s and xxx''s here' from dual union all
  select 'xyz-xyz-xyz-xyz-xyz' from dual)
select
  str,
  regexp_replace(str,'[^xy]') as mod_str
from t;
STR                                             MOD_STR
aby,xc dx                                       yxx
an x and a y and few more yyyy's and xxx's here xyyyyyxxx
xyz-xyz-xyz-xyz-xyz                             xyxyxyxyxy
SQL>
SQL>pratz

Similar Messages

  • Program to count the no. of times a character occurs in a string.

    program to count the no. of times a character occurs in a string.
    Say if u have a method :- Countclass(string s,char c) then using this u should be able to count a char ' T' in the string ="TESTING".
    So it is appering 2 times.
    How to count it.

    int countChar(String s, char c) {
       int count = 0;
       for (int i=0; i<s.length(); i++) {
          if (s.charAt(i) == c)
             count++;
       return count;
    }

  • Character counter does not display data on IE when counter is 0

    Hi,
    I am implementing a character counter in ADF using Javascript (referencing this http://www.oracle.com/technetwork/developer-tools/adf/learnmore/10-char-input-counter-169133.pdf).
    I display the string --> 'x' characters left
    The problem that I am facing is: when my character counter becomes 0 (can no longer enter any text, the maxlimit of the input field is reached) then on IE browsers, it does not show the character '0'. It displays a blank. On Firefox and Chrome, however, the UI gets displayed as expected i.e. 0 characters left.
    Can I get any pointers how to fix this on IE. Have tested with IE versions 7,8,9. JDev version is 11.1.1.5.0
    Here is the code snippet that I am using:
    Javascript:
    function showCharacterCount(event) {
    var keyCodePressed = event.getKeyCode();
    if (keyCodePressed == AdfKeyStroke.TAB_KEY
    || keyCodePressed == AdfKeyStroke.ARROWLEFT_KEY
    || keyCodePressed == AdfKeyStroke.ARROWUP_KEY
    || keyCodePressed == AdfKeyStroke.ARROWRIGHT_KEY
    || keyCodePressed == AdfKeyStroke.ARROWDOWN_KEY) {
    event.cancel();
    else {
    textfield = event.getCurrentTarget();
    textfieldValue = event.getSource().getSubmittedValue();
    textfieldLength = textfieldValue.length;
    textfieldMaxLength = textfield.getMaximumLength();
    o = AdfPage.PAGE.findComponent('characterCounter');
    characterCounterValue = o.getValue();
    characterCounterValue = textfieldMaxLength - textfieldLength;
    o.setValue(characterCounterValue);
    UI:
    <af:panelGroupLayout id="pgl3" layout="horizontal">
    <af:outputText id="characterCounter" clientComponent="true" value="325"
    inlineStyle="text-align:right; display:block; width:100.0px;"
    binding="#{viewScope.myBean.characterCounterBndg}"/>
    <af:outputText value="characters left" id="ot7"
    inlineStyle="padding-left:5.0px;"/>
    </af:panelGroupLayout>
    <af:inputText id="it2" rows="4" columns="53"
    value="#{viewScope.myBean.text}" maximumLength="325" clientComponent="true"
    simple="true">
    <af:clientListener method="showCharacterCount"
    type="keyUp"/>
    </af:inputText>
    Thanks in advance.

    Try converting from dynamic data, that seems to take care of the problem. Also, you could use the regular field point VIs instead of the FP express VI. Check out the attached VI.
    -Alan A.
    Attachments:
    FP_Read.vi ‏30 KB

  • Move text from one column to another depending on character count

    Hello,
    I am trying to find a way to have text start in a specific column depending on the character count.
    Basically our site will have 3 columns. For example if the text only has about 300 Characters - it would start in the right column. If it had between 301 & 600 characters - it would start in the middle column and run to the right column. If it had more than 601 characters - it would start in the left column and run to the middle then right column.
    Is this possible?
    Thanks in advance for any help!
    James

    If you look at the String class you can probably devise a series of steps to do what you want using some basic logic.  The String class has a length property that tells you how many characters it contains.  Assuming you wouldn't want to split words, you could use something like the indexOf method to find the nearest blank space following the 300th character.  Then you would be wanting to build different strings for the different segments you create.

  • How do I limit the character count in a text field?

    I'm creating a form for co-workers to use when creating web content. I need to restrict their character count for items like headlines, titles, subtitles, etc. Any suggestions on a ready-made form to use out there? And how can I limit those fields so they don't generate content that will then need to be edited down?
    Thanks,
    EAW

    Check out this post:
    http://forums.adobe.com/message/4364378
    Randy

  • How do I found the character count in a document

    How do I find character count and word count in a doumen on my IMc?

    Created with which application?

  • Inserting new line in script output based on character count

    Dear All,
    I want to print amount in words on cheque. Condition is if on the first line the character
    count reaches 40 the rest words should be printed in next line. Also amount in word
    should be printed  on the same line. 
    I have the internal table values itab-amtwords(amount in words and ) itab-rbetr(amount in number)
    I want to print them something like this -
       Sixty seven crore eighty five lakh twelve thousand     
       fourty five                                                                678512045.00
    the amount in word should come in second line only. The amount in word if reaches certain point
    the rest word should print in second line.
    How to write the logic in script editor
    Regards,
    Sandeep

    the amount in number should print in the second line.
    2163126312.00
    regards
    sandeep
    Edited by: Sandeep Sahoo on Apr 17, 2009 4:34 PM
    Edited by: Sandeep Sahoo on Apr 17, 2009 4:38 PM

  • Inserting new line in output based on character count +sapscript

    Dear All,
    I want to print amount in words on cheque. Condition is if on the first line the character
    count reaches 40 the rest words should be printed in next line. Also amount in word
    should be printed  on the same line. 
    I have the internal table values itab-amtwords(amount in words and ) itab-rbetr(amount in number)
    I want to print them something like this -
       Sixty seven crore eighty five lakh twelve thousand     
       fourty five                                                                678512045.00
    the amount in word should come in second line only. The amount in word if reaches certain point
    the rest word should print in second line.
    How to write the logic in script editor
    Regards,
    Sandeep
    Moderator message - Cross post locked
    Edited by: Rob Burbank on Apr 17, 2009 10:46 AM

    the amount in number should print in the second .
    2163126312.00
    Regards,
    Sandeep

  • Character Counter for ADF 11g RichTextEditor

    I am rewriting an application in 11g RichFaces. The original app had a text area that had a maximum allowable length and used a Javascript function to display to the user how many characters they had left as they were typing. In the new app, I have replaced this functionality with the WYSIWYG RichTextEditor, but would like to give them the same functionality that they had before. I would like to display, as they type, a character count. The count needs to be of the actual displayed characters, not the count of HTML characters that are generated behind the scenes by the RichTextEditor.
    Is this possible?

    huh? waking up a 1-year-old thread to ask an unrelated question (and a demand for us to write your code for you to wit)?

  • Non-hex character in a hex string error message

    Hi everyone,
    I encountered n error message in Illustrator "Acrobat PDF File Format is having difficulties. Non-hex character in a hex string." when trying to open a particular file.
    File was originally created on a Windows 7 PC, tried opening file on Mac OS 10.7.5, same Illustrator version 18. Also tried opening in PDF, Distiller, but didn't help.
    Did tried to change Illustrator Preferences in both Windows and Mac, following the steps in the TecNote:
    http://kb2.adobe.com/cps/500/cpsid_50031.html
    When trying to open the file from the File > Open menu, with the keys held down, it did not open a blank file window, neither did it created a duplicate copy in the Finder where the file is located.
    The file in question had about 15 artboards,  a few embedded images, approx 2.6MB size.
    Any suggestions/assistance would be greatly appreciated.
    Thank you.

    Hi Monika,
    The file was .ai file, as mentioned earlier, was created in Illustrator ver 18.
    Not emailed, stored in the folder, on the Windows PC, not a server. Last saved few days ago, tried to reopen the file from the same computer, but could no longer opened.
    No, Illustrator did not crash, just the error message "Acrobat PDF File Format is having difficulties. Non-hex character in a hex string."

  • Non-hex character in a hex string

    My Illustrator file will not open in Illustrator and I get the "non-hex character in a hex string" window whenever I try to open it. It does open in Acrobat but nothing else. I can't even save it as a pdf file..
    Is there any way I can get around that or fix it?

    karam,
    The first thing to try is to use File>Place in a new document and see how much, if anything, is saved this way.
    The next thing to try is to repair the file code, which is more difficult. The basics are told in this TechNote, the actual recovery consists of changing/adding/deleting code.
    http://kb2.adobe.com/cps/500/cpsid_50031.html

  • Character Count Bug? (IDCS4 WinXPSP3)

    Here's a little bug. Apologies if it's been mentioned before.
    The Info palette tells you how many characters your selection contains. If you select the word "hello" the Info p. says: "Characters: 5"
    If you select an entire line that happens to contains a foontnote marker, the character count includes all the characters in the footnote itself. So while an average line might have 70 characters, a line containing a footnote might appear as though it has 1000 characters or more (depending on the length of the footnote).
    Now, as scripters will be aware (and please correct me if I'm wrong), the footnote marker is the parent of the footnote text. So that's probably where the bug comes in.
    But I don't think this should be reflected in the Info palette.
    Thanks,
    Ariel

    Have you reported it? Adobe - Feature Request/Bug Report Form

  • Character count

    Hi,
    As most of the InDesign User know info window show text box character count, words even the paragraphs their in selected text box.
    I want to know is their a way to see these all text layer stats in Photoshop?
    Thanks
    Jamal

    You could probably use a Script to evaluate a selected Type Layer. (It may be difficult, though, to get the word count depending on your definition of word.)
    To have that feedback on display permanently you probably would have to create an html5 Panel.

  • Dynamic character count

    Is it possible to have a display of how many characters are showing in a text box (without highlighting text) and when the size of the box is changed the character count is updated.
    For example if I have a text box and I have more text in that box then can fit so it is "busting out of the box"... can I get a character count display telling me how many characters are in the text box disregarding the overflow text... and as I pick up the text box handles and start resizing the text box the character count display updates on the fly... only counting the characters visible in the text box and not the ones that have busted out of the box.
    Regards, Tim

    There appears to be something wrong with your InDesign. This is what it looks like for me:
    Try resettting your preferences.

  • Character count display problem in IE

    Hi all,
    I have implemented a character counter in ADF using Javascript (referencing this http://www.oracle.com/technetwork/developer-tools/adf/learnmore/10-char-input-counter-169133.pdf).
    The problem that I am facing is: when my character counter becomes 0 (can no longer enter any text, the maxlimit of the input field is reached) then on IE browsers, it does not show the character '0'. It displays a blank. On Firefox and Chrome, however, the UI gets displayed as expected i.e. 0 characters left.
    Let me know how to fix this on IE. Have tested with IE versions 8,9. JDev version is 11.1.1.7.0.
    Thanks,
    Anu.

    Hi,
    debugging the JavaScript to see what the value of the variable really is is a good start. If it turns out that it is becoming null, then you could use a if() case in that whenever the value is null you set it to 0. If the value however is correct but just doesn't render then you can try and transform it to a character instead of a number to see if the numeric output is the problem. This is how I would address the problem
    Frank

Maybe you are looking for