Get number of character within a String by number of pixels

How can i get the number of character within a String
by a width value...
for example..
i have a String = "1234567890abcdefghi.........."
and when i give the width "10"
i will get the String "12".
or the number of charcter..
or somthingggggggggggggggg
please help..
Shay

i solved this...
by doing somthing similar..
i made a for loop on all character
and evrey time i am get a sub string from the 0 till the loop index..
and i am chashing the last string
so when a sub width is greater the the requested width
i am returning the lst cashed result
thanks.. all..

Similar Messages

  • How to get a set of character within a string?

    Hi,
    I need to cut a set of character within a string. I have tried everthing but I need help.
    Example.
    Database Version 11.2.0.3
    create table tst_string (message varchar2(600));
    insert into tst_string values ('ANR0166I Inventory file expiration finished processing for node OSOGBO, filespace OSOGBO\SystemState, copygroup BACKUP and object type GROUP BASE with processing statistics: examined 43, deleted 43, retrying 0, and failed 0. (SESSION: 1506, PROCESS: 2)');
    insert into  tst_string values ('ANE4175I Starting Full VM restore of VMware Virtual Machine ''mfujiwara'' target node name=''VC1_DC1'', data mover node name=''VC1_DC1_DM3''  (SESSION: 3780)');
    commit;
    select * from tst_string;
    MESSAGE
    ANR0166I Inventory file expiration finished processing for node OSOGBO, filespace OSOGBO\SystemState, copygroup BACKUP and object type GROUP BASE with processing statistics: examined 43, deleted 43, retrying 0, and failed 0. (SESSION: 1506, PROCESS: 2)
    ANE4175I Starting Full VM restore of VMware Virtual Machine 'mfujiwara' target node name='VC1_DC1', data mover node name='VC1_DC1_DM3'  (SESSION: 3780)
    ## I want get
    # From first line following values:
    node OSOGBO
    filespace OSOGBO\SystemState
    examined 43
    deleted 43
    retrying 0
    failed 0
    # From second line
    mfujiwara
    VC1_DC1
    VC1_DC1_DM3Any help can be useful...
    Thanks in advance.

    Hi Frank,
    It looks like message can be seen as delimited lsit of sub-messages, where a number of different characters (perhaps ',' amd ':') may serve as delimiters. Each sub-message may or consist (entirely or in part) of something you want to display.Yes. In my first case where is "ANR0166I" I want get the characteres before "," (e.g "OSOGBO," I want get "OSOGBO") excluding "(SESSION: 1506, PROCESS: 2)"
    Would a user-define PL/SQL function be okay for you?Yes.. no problem.
    I'm not good with shell script, but will try show what I want using SHELL commands:
    See this example:
    ### I create a file named "tst_string"
    $ vi tst_string
    ANR0166I Inventory file expiration finished processing for node OSOGBO, filespace OSOGBO\SystemState\NULL\System State\SystemState, copygroup BACKUP and object type GROUP BASE with processing statistics: examined 43, deleted 43, retrying 0, and failed 0. (SESSION: 1506, PROCESS: 2)
    ## So I used a function sed to get my desired values. The command bellow is poor, but My point is the result.
    $ cat tst_string | sed 's/ANR0166I.*node //g' | sed 's/, filespace//g' | sed 's/, copygroup BACKUP and object type GROUP BASE with processing statistics: //g' | sed 's/. (SESSION.*//g' | sed 's/, deleted//g' | sed 's/, retrying//g' | sed 's/, and failed//g'
    OSOGBO OSOGBO\SystemState\NULL\System State\SystemState 43 43 0 0The result was:
    NODE     FILESPACE                              Examined     Deleted     Retrying        Failed      
    OSOGBO      OSOGBO\SystemState\NULL\System State\SystemState     43           43      0           0I will go check the links wich you mentioned.
    Thanks

  • Count a character within a string

    Give a string, what function can I use to count how many a particular character in the string. For example:
    "abc;def;ghi;xyz"
    I want to find out how many ";" in this string.
    Thank you

    And of course, if the researched character is not in the given string, then you'll return null, to return 0, you'll need a NVL.even if it is in the string you might need a nvl in Vamsi Kasina's solution:
    SQL>  select length (';') - length (replace (';', ';')) cnts
      from dual
          CNTS
    1 row selected.Better:
    SQL>  select nvl(length (';'),0) - nvl(length (replace (';', ';')),0) cnts
      from dual
          CNTS
             1

  • [JS - CS3]  Not able to add 'Superscript' style to a character within a string

    Hello fellow experts...
    I'm stuck with trying to change the style of a character from Normal to Superscript!
    b Situation:
    I have a string - 'myCourseTitle' - that has both CharacterStyles & ParagraphStyles applyed and could include the following character/Word:
    > '®' (Character)
    'OperateIT' (Word)
    b Requirements:
    I am wanting to add the style 'Superscript' to both the '®' characters and 'IT' from the words 'OperateIT', while keeping their initial CharacterStyles & ParagraphStyles!
    b My Starting Block:
    if (myCourseTitleField.editContents == ""){
    var myCourseTitle = "-no title has been defined-";
    }else{
    var myCourseTitle = myCourseTitleField.editContents;
    // The contents should now be checked for '®' characters and 'OperateIT'
    // And set to Superscript if found!
    if (myCourseTitle.indexOf("®") != 0){
    alert("Registered Trade Mark '®' found in Course Title at position:"+myCourseTitle.indexOf("®")+"\rThis will be set to 'Superscript' formatting", "WARNING '®' within Course Title",)
    I have tried many scripts, including the attached sample 'FindChangeByList.jsx' script - but to no avail!
    Can anyone help me - point me in the right direction to start looking?
    Thanks in advance
    Lee

    Hi Lee,
    In the example, you're trying to apply InDesign formatting to a JavaScript string (from an InDesign dialog box text field). That won't work, because the JavaScript string doesn't know anything about InDesign text objects.
    I'm assuming, however, that what you want is to change the formatting of the text on your page. To do that, you can use the findText method on the text, story, or document. Here's an example (the relevant part is the "mySnippet" function--the rest is just setting up an example):
    main();
    function main(){
    mySetup();
    mySnippet();
    function mySnippet(){
    //Clear find text preferences.
    app.findTextPreferences = NothingEnum.nothing;
    app.changeTextPreferences = NothingEnum.nothing;
    app.findTextPreferences.findWhat = "®";
    app.changeTextPreferences.appliedCharacterStyle = app.documents.item(0).characterStyles.item("superscript");
    app.documents.item(0).changeText();
    //Reset find/change text preferences.
    app.findTextPreferences = NothingEnum.nothing;
    app.changeTextPreferences = NothingEnum.nothing;
    //Reset find/change GREP preferences.
    app.findGrepPreferences = NothingEnum.nothing;
    app.changeGrepPreferences = NothingEnum.nothing;
    //There's probably a way to do this in a single pass, but I'm short on time...
    app.findGrepPreferences.findWhat = "\\l(?<=)IT";
    app.changeGrepPreferences.appliedCharacterStyle = app.documents.item(0).characterStyles.item("superscript");
    app.documents.item(0).changeGrep();
    app.findGrepPreferences.findWhat = "\\l";
    app.findGrepPreferences.appliedCharacterStyle = app.documents.item(0).characterStyles.item("superscript");
    app.changeGrepPreferences.appliedCharacterStyle = app.documents.item(0).characterStyles.item("[None]");
    app.changeGrepPreferences.position = Position.normal;
    app.documents.item(0).changeGrep();
    app.findGrepPreferences = NothingEnum.nothing;
    app.changeGrepPreferences = NothingEnum.nothing;
    //mySetup simply takes care of setting up the example document.
    function mySetup(){
    var myDocument = app.documents.add();
        var myPage = app.activeWindow.activePage;
    //Create a text frame on page 1.
    var myTextFrame = myPage.textFrames.add();
    //Set the bounds of the text frame.
    myTextFrame.geometricBounds = myGetBounds(myDocument, myPage);
    //Fill the text frame with placeholder text.
    myTextFrame.contents = TextFrameContents.placeholderText;
    myTextFrame.insertionPoints.item(0).contents = "OperateIT®\r";
    myTextFrame.paragraphs.item(-1).insertionPoints.item(0).contents  = "OperateIT®\r";
    var myHeadingStyle = myDocument.paragraphStyles.add({name:"heading"});
    var mySuperscriptStyle = myDocument.characterStyles.add({name:"superscript", position:Position.superscript});
    function myGetBounds(myDocument, myPage){
    var myPageWidth = myDocument.documentPreferences.pageWidth;
    var myPageHeight = myDocument.documentPreferences.pageHeight
    if(myPage.side == PageSideOptions.leftHand){
      var myX2 = myPage.marginPreferences.left;
      var myX1 = myPage.marginPreferences.right;
    else{
      var myX1 = myPage.marginPreferences.left;
      var myX2 = myPage.marginPreferences.right;
    var myY1 = myPage.marginPreferences.top;
    var myX2 = myPageWidth - myX2;
    var myY2 = myPageHeight - myPage.marginPreferences.bottom;
    return [myY1, myX1, myY2, myX2];
    Thanks,
    Ole

  • How to get the numeric character in a string

    Hi Experts,
    I have the following requirement.
    I am double clicking on the number of a string and I need to get the number as the output.
    I have string  like
    String1 : "Account Number 19292 is closed"  I am double clicking on 19292
    I want the output as 19292
    String2 : "AccountNumber19292isclosed"   I am double clicking on 19292
    I want the output as 19292
    String3: "Account Number1929 2 isclosed"  I am double clicking on 1929
    I want the output as 1929 and not 19292
    String4 :"Account Number 1929 2is closed" I am double clicking on 2
    I want the output as 2.
    Thanks in Advance,
    Raju

    Hi Raju,
    All possible solutions should more or less do the following two steps:
    <ol>
    <li>Check if at the given offset is a number: If yes, retain all consecutive numeric characters from the offset; otherwise stop.</li>
    <li>Retain any consecutive numeric characters preceding the number at the given offset and remove all other characters</li>
    </ol>
    Pretty trivial stuff, but the interesting challenge is actually to come up with the solution with least amount of coding (and ideally still understandable). I have a solution that is pretty short, though not really obvious for people not knowing about regular expressions...
    So here's the coding (relevant part in the form) and a quick test harness to check out what it does:
    data:
    TXT type STRING,
    NUM type STRING,
    OFF type I,
    LEN type I.
    TXT = '0Account12 Number 345 6 78isclosed9.9'.
    LEN = strlen( TXT ).
    do LEN times.
      OFF = SY-INDEX - 1.
      perform EXTRACT_NUMBER using    TXT
                                      OFF
                             changing NUM.
      write: /(3) OFF, ':', (5) NUM, TXT(OFF) inverse no-gap, TXT+OFF.
    enddo.
    * Return number at given offset in string (empty if no number present)
    form EXTRACT_NUMBER using    TXT        type STRING
                                 VALUE(OFF) type I
                        changing NUM        type STRING.
      NUM = TXT.
      replace regex '^(\d+).*$' in section offset OFF of NUM with '$1'.
      if SY-SUBRC = 0.
        replace regex '^.*[^\d](\d*)$' in NUM with '$1'.
      else.
        NUM = ''.
      endif.
    endform.
    I think this should match your requirements. Let's see if somebody comes up with a solution with less lines...
    Cheers, harald

  • Correct way to search for character within a string

    I am trying to search for the occurrence of a "(" within a text string - unfortunately my code is reported as incorrect.
    I extract the text correctly but cannot create the search statement correctly:
    var mylistpgftext = pgf.GetText (Constants.FTI_String)   
    for (var i=0; i < mylistpgftext.length; i++)             
        var mylistitem = mylistpgftext[i].sdata              
        var mybracketpos = mylistitem.search(/(/i)    --------------error line-----------------       
        if (mybracketpos != -1)                              
          alert(mylistitem)                                  

    Hi Bob, I did not test this, but I think the problem is an unescaped character in your regular expression. Try this.
    var mybracketpos = mylistitem.search(/\(/i);
    Notice the backslash before the open parens that you are searching for.
    -Rick

  • Unable to use character within a String in a skeleton file

    The < character appears to be a special character to skeleton files. I am unable to use this character to built a string in a skeleton file.
    For instance, using this block:
    <jsp:scriptlet>
    String sample = "<test";
    </jsp:scriptlet>
    Results in this error: String literal is not properly closed by a double quote.
    It's also not allowed as a character either:
    <jsp:scriptlet>
    String sample = "[test";
    sample = sample.replace('[','<');
    </jsp:scriptlet>
    This block has the error: Invalid character constant.
    It appears the < character is a special character in the way skeleton files parse, but I can't find any way to escape it like normal special characters.

    That actually puts < into the string, which the browser won't interpret as HTML.
    This also breaks the Workshop UI saying the string literal isn't terminated. It doesn't like & or ; characters in strings either. However, it will still compile and run.
    Edited by btiminey at 01/31/2008 8:34 AM
    Edited by btiminey at 01/31/2008 8:35 AM

  • How to count number of occurences of a character  in a string

    I want to get the count of occurences of a character within a string. Is there any function for this or should i go for a PLSQL.
    For example is the sting is "occurences" & if i search for character "c", the answer should be 3.
    Regards,
    Sunil.

    SQL> select length('occurence') - length(replace('occurence','c')) from dual;
    LENGTH('OCCURENCE')-LENGTH(REPLACE('OCCURENCE','C'))
    3

  • OBIEE - Find position of the last occurrence of a charcter within a string.

    Hi,
    I have a requirement in 11.1.1.6.9 to be locate the position of the last occurrence of a character within a string.
    i.e. Given the following, I would want to locate the last "/":
    This/is/an/exampleI would like to return a value of 11. Now, there could be any number of "/" so I can't always locate the nth one - it must be the last one.
    Anyone any ideas?
    Thanks,
    John

    Your requirement is not complete. just in case you want to extract the last part 'example' just use substring and replace to trim up to required part.
    You may have to go for the same for multiple times.
    ETL is the best to handle this than BI.
    BTW: Check this How to use locate function if multiple occurences of same character
    Edited by: Srini VEERAVALLI on May 10, 2013 10:25 AM
    Good that given link is helped you to solve it ;)
    Edited by: Srini VEERAVALLI on May 13, 2013 7:47 AM

  • NewLine Character in the String received from Interactive Adobe Form

    Hello Experts,
    Following is the issue we have with interactive Adobe Form
    We have a text area within the form. User enters the text in multiple lines in this text area.
    We are calling a backend function module designed in SE37 that accepts and process the data from the adobe form.  We are also processing the string data user enters in the text area.
    When we receive the string from the form, the newline character within the string is displayed as '#' in the debugger. We tried splitting this string using cl_abap_char_utilities=>newline and cl_abap_char_utilities=>cr_lf  but NO luck. Though in the debugger we see cl_abap_char_utilities=>newline  as '#'  in the debugger and also '#' is present within the string, for some reason when string is processed to find cl_abap_char_utilities=>newline, we can find/locate it.
    Because ABAP code is not able to identify the newline character within the string received from Adobe form, we are not able to maintain the formatting of the string as it was entered in the form.
    Any help to resolve this issue is appreciated.
    Thanks in Advance.
    Regards,
    Bhushan

    Hi Bhushan,
    I was going through your issue, and I feel this is something you can do with scripting. Basically you should read whole string and find the new line character and replace with a space or comma, as per your requirment.
    Do like following:
    In the exit event of the field select java script and write following code:
    var strng = this.rawValue;
    strng.replace(/\n/g, " ");
    above im reaplcing new line with a space.
    I think it should work I have not tested it. Pls update if you test it .
    Regards,
    Ravi.D

  • LAST CHARACTER OF A STRING

    Hi Gurus,
    I want to get the last character of a String.For Ex.
    I have name = 'ZXCDFG":?'
    And I want to print the last character ?.
    How can i do it.
    Thanks in Advance.

    Hi Pradeep,
    Just find the String Length and use the offset commands
    DATA : DATA TYPE CHAR20 'ABCDEFG',
    DATA : DATA1,
    DATA : LEN TYPE I.
    LEN = STRLEN( DATA ).
    LEN = LEN - 1.
    DATA1 = DATA+LEN(1).
    Regards
    Kumar M.

  • Separating character and number within the string

    I want to separate the character and the number within one string.
    For example,
    12345ABCD (the numbers and character may differ in lengths)
    I want to separate into two different string of 12435 and ABCD.
    Your help would be greatly appreciated.
    Thanks!

    here is an example:
    sample_separator.sql
    declare
      i        number := 0;
      j        number := 0;
      x        number := 0;
      vBasis   Varchar2(40) := '12345ABCD';
      vString1 Varchar2(40);
      vString2 Varchar2(40);
    begin
      for x in 1 .. length(vBasis) loop
        for i in 0 .. 9 loop
          if substr(vBasis,x,1) = to_char(i) then     
            vString1 := vString1 || substr(vBasis,x,1);
          end if;
        end loop;
        for j in 65 .. 90 loop
          if substr(vBasis,x,1) = chr(j) then
            vString2 := vString2 || substr(vBasis,x,1);
          end if;
        end loop;   
      end loop;
      dbms_output.put_line('vString1: '||vString1);
      dbms_output.put_line('vString2: '||vString2);
    end;
    /when run:
    SQL> @r:\sample_separator.sql;
    vString1: 12345
    vString2: ABCD
    PL/SQL procedure successfully completed.
    SQL> hope this helps.

  • How to get each character in a string

    as in 'C' we use arrays to get each character of a string stored in array.how can we get each character of a string stored in a variable.

    Hi,
    For that you need to do offset.
    for example one variable called VAR contains string 'HUMERAH'.
    if you want each character of that string then you need to decalre as many variable as the number of string.
    like
    data : var1(1),
             var2(1),
    var(3),
    var(4).
    var1 = var+(1).
    var2 = var+1(1).
    var3 = var+2(1).
    var4 = var+3(1).
    now var1,var2,var3,var4. contains the single characters.
    Regards,
    Guru
    mark helpful answers

  • Findind out the number of lines within a string - using buffered reader

    Hi All,
    Want to know the number of lines within a string..Sample code is there for reference..could u help me out how to have the number of lines in a string without java comments (i.e string within /**------*/ and // should be eliminated)
    public class ReadLines {
         public static void main(String[] args) throws Exception{
              ReadLines rl = new ReadLines();
              rl.readLines();
         void readLines() throws Exception{
              String str = "/** This is a test message\n"+
                   "* for testing\n"+
                   "*/\n"+
                   "import java.io.*\n"+
                   "// this is again comment\n"+
                   "public class ReadLines {\n"+
              BufferedReader reader = new BufferedReader(new StringReader(str));
              String line = "";
              int count = 0;
              while ((line = reader.readLine())!= null )
                   //line = reader.readLine();
                   count++;
              System.out.println(count);
    }Thanks
    MK

    Hi
    What you need to do is parse the file in such a way that you read /*, */ and // as tokens. By that I mean rather than read a line at a time (although I'm sure you could), read it character by character. So every time you reach a new line character then increment the counter. But there are two casaes when you don increment the counter they are:
    If you encounter a / followed by * then keep reading but if you encounter a newline character then DONT increment the counter ONLY continue counting when you read a * followed by a / (as this is the end of the comment)
    If you encounter / followed by another / then do not count that particular line and go to the next line and continue counting from there.
    Where I've written 'continue counting' this is subject to the lines that follow not conforming to the above two cases.
    I hope this helps.

  • Get first character from a String

    Hi!
    I've got a problem with the login of my program:
    I want to get the first character out of a String to select two types of users.
    eg.
    login "a20202" --> a --> first kind of user or
    login "b20202" --> b --> second kind of user
    Can you please help me?
    Bye
    Liz

    Am I on way to challenge the Worst Code Awards 2004 ? Let me have a go ... It is a far superior code-generating version :)
    Kept to ascii-range for the benefit of your monitor (and eyes):class NoMyWayIsFarSuperior {
         public static void main(String[] args){
              System.out.println("public static char getFirstChar(String message){");
              for(int k = 0; k < 256; k++){
                   System.out.println("  if(message.charAt(0) == " + k + ") return '" + ( (char) k) + "';");
              System.out.println("  throw new Exception(\"First char not within ascii range ... Please try again.\"); ");
              System.out.println("}");
    } The potential for optimisation is endless! :)

Maybe you are looking for

  • Export Address Book to Outlook?

    What's the best way to export my OS X Address Book to my secretary's PC, where she runs Outlook?

  • Is anyone else getting calls from Lagrange, GA? (706)594-**** area?

    I have been getting calls from:706-594-****, 706-594-****, 706-594-****, 706-594-****.  If I let it go to voice mail. They won't leave a message. and if I answer it they hang up. It's my belief that they are a service in determining if the line is ac

  • Do I need to uninstall academic version before installing retail version?

    I've been using my academic version of Final Cut Studio professionally and decided that I would buy the retail version when Studio 3 came out. So I purchased the New Version and am about to install. Since this is a full version, and not an upgrade ve

  • ITunes 5 & 6 Download Problems

    For the past couple of days I could not buy/download music with iTunes 5 (no problems in the past). Therefore, I tried downloading iTunes 6 to solve this problem and now I can't even open iTunes at all. I've tried to re-load iTunes 6 three or four ti

  • Event handling, incrementing with buttons

    Hey struggling a little and hope someone out there might be able to help out i need to find out how to make a new line appear everytime a button is pressed, the lines are all exactly the same length, just in a different position to the last the lines