Finding first numeric in string

Hi,
I am trying to find a way I can find the first numeric in a string.
This works but I have to do it 10 times:
String vtemp = vdoc.indexOf('1');Example of data:
AB123
CDE456
ABCD789I am trying to find a way to do something like: indexOf(any number); So I can get the result in one line of code.
Thanks for any help

Hi GaryJSF,
You have to convert your string into an array of characters and for each character, check if it's a digit until you find the first one :
String str = "ABC123";
char[] crs = str.toCharArray();
for (int i = 0; i < crs.length; i++) {
    if (Character(crs).isDigit()) {
System.out.println("first index = " + i);
break;

Similar Messages

  • How to find first non zero value from the numeric value or string?

    Hiii, Every body
              I have one numeric indicator in which some valuse is coming with the decimal value, lets say 0.00013, now i want to find the first non-zero value from this numeric indicator, then what should i do to do so? i have converted it in the string, but i could not find any method to find first non-zero value from that string or either from the numeric indicator????
          Can you please help me, how to do it? i have attached the vi and write all the description inside.
    Thanks in Advance,
    Nisahnt
    Attachments:
    Find first nonzero.vi ‏20 KB

    Just convert it to an exponential string and take the first character .
    Message Edited by altenbach on 05-10-2006 08:00 AM
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    FisrstNonzeroChar.png ‏3 KB
    FindFirstNonzeroCharacter.vi ‏20 KB

  • Newbie question: cannot find symbol symbol: class STRING

    I've just decided to teach myself some java, and on my first try something's going wrong and I don't know what it is.
    I'm currently doing this tutorial: http://java.sun.com/docs/books/tutorial/uiswing/learn/example1.html
    and everything is good until I try to compile it and I get this error in the cmd
    HelloWorldSwing.java:30: cannot find symbol
    cannot find symbol
    symbol: class STRING
    everything has been written verbatim from the tutorial, including "import javax.swing.*;"
    What's wrong with it and how do I fix it?

    Hi,
    I saw the coding that You had given a link in your post. Change the following
        public static void main(String[] args) {bye for now
    sat

  • Finding number in a string

    I am trying to find a number in a string from my database to replace it.  Here is my funciton:
    function findUserID($friendsString, $userToFind){
              echo $friendsString . " " . $userToFind;
              $pos = strpos($friendsString,$userToFind);
              if($pos){
                        return true;
              return false;
    it returns "25,29 25".  How can it not find 25 in that string?

    I understand that it starts at 0.  it should still work.  i had it working before.  i must've changed something. 
    here is my code for passing to the function:
    $query = mysql_query("SELECT friends, pendingFriendRequest
    FROM members
    WHERE username = '$userID'");
    if (mysql_affected_rows() > 0) {
              $row = mysql_fetch_array($query) or die(mysql_error());
              $friends = $row['friends'];
              $pendingFriends = $row['pendingFriendRequest'];
    // If the user exists in the waiting list, then
    //continue (we must confirm that they are first by checking the DB
    $test = findUserID($pendingFriends, "25");
    if($test){
              // If they are, then continue to add them
              $test = confirmFriend($pendingFriends, "25");
              if($test) {
                        echo "<br />You have confirmed " . findUserName(24) . "as a friend.";
              } else {
                        echo "<br />Error: Please try again, or contact us.";
    } else {
              echo "<br />Error: You either have this person as a friend already, or there was an internal error.";

  • How to find number from text string??

    Hi All,
    Can you tell me how to find/ fetch number from string?
    is there any function module  for this.?
    for example , I have string like "+++++1000000589+++"
    and I need to fetch the invoice no 1000000589 from the above string..then  How to do that? Letters may come first or number may come first and latter text...
    Regards,
    Mrunal

    You can do like this.
    The below mentioned is code separate material
        DO 18 TIMES.
          LV_C = LV_C + 1.
          LV_C1 = LV_C - 1.
          IF  GW_MATNR-MATNR+LV_C1(1) CN '0,1,2,3,4,5,6,7,8,9' .
            IF ( ( LV_MAT EQ SPACE ) ) ."  and ( lv_prefix eq space ) ) .
              LV_PREFIX = 'X'.
              CONCATENATE GW_TEMP-PREFIX GW_MATNR-MATNR+LV_C1(1) INTO
              GW_TEMP-PREFIX.
            ELSE.
              LV_SUFFIX = 'X'.
              CONCATENATE GW_TEMP-SUFFIX GW_MATNR-MATNR+LV_C1(1) INTO
              GW_TEMP-SUFFIX.
            ENDIF.
          ELSEIF ( ( LV_SUFFIX EQ SPACE ) ) .
            LV_MAT = 'X'.
            CONCATENATE GW_TEMP-MATNR1 GW_MATNR-MATNR+LV_C1(1) INTO
            GW_TEMP-MATNR1.
          ELSEIF ( ( LV_MAT EQ 'X' ) ) .
            CONCATENATE GW_TEMP-SUFFIX GW_MATNR-MATNR+LV_C1(1) INTO
            GW_TEMP-SUFFIX.
          ENDIF.
        ENDDO.

  • Query engine : Can not find DSN in Connection String

    DearSir/Madam,
    Opearating System Windows 7 Professional(32-bit).
    I am using Application, which is developed : Visual basic 6.0(32-bit), Report Writer : Crystal Report 9.2.693(32-bit) and database: Oracle 9.2.0.10(32-bit).
    ODBC Data source : System DSN created and Connection established (Based on Driver : CR ORACLE ODBC Driver 4.10 (cror818.dll))
    In windows 7 environment Data Base connectivity and data fetching also wroking fine.
    My problem is while running reports it display error as "Query engine : Can not find DSN in Connection String"
    I want run time reports.
    For your kind information, at the same time in Windows XP Professional there is no problem found and working fine.
    Kindly help me.
    Thanks and regards,
    Swarup

    Crystal Reports 9.x is not supported on Win 7. See the following wiki:
    http://wiki.sdn.sap.com/wiki/x/b4JiAw
    - Ludek

  • [Forum FAQ] How to find and replace text strings in the shapes in Excel using Windows PowerShell

    Windows PowerShell is a powerful command tool and we can use it for management and operations. In this article we introduce the detailed steps to use Windows PowerShell to find and replace test string in the
    shapes in Excel Object.
    Since the Excel.Application
    is available for representing the entire Microsoft Excel application, we can invoke the relevant Properties and Methods to help us to
    interact with Excel document.
    The figure below is an excel file:
    Figure 1.
    You can use the PowerShell script below to list the text in the shapes and replace the text string to “text”:
    $text = “text1”,”text2”,”text3”,”text3”
    $Excel 
    = New-Object -ComObject Excel.Application
    $Excel.visible = $true
    $Workbook 
    = $Excel.workbooks.open("d:\shape.xlsx")      
    #Open the excel file
    $Worksheet 
    = $Workbook.Worksheets.Item("shapes")       
    #Open the worksheet named "shapes"
    $shape = $Worksheet.Shapes      
    # Get all the shapes
    $i=0      
    # This number is used to replace the text in sequence as the variable “$text”
    Foreach ($sh in $shape){
    $sh.TextFrame.Characters().text  
    # Get the textbox in the shape
    $sh.TextFrame.Characters().text = 
    $text[$i++]       
    #Change the value of the textbox in the shape one by one
    $WorkBook.Save()              
    #Save workbook in excel
    $WorkBook.Close()             
    #Close workbook in excel
    [void]$excel.quit()           
    #Quit Excel
    Before invoking the methods and properties, we can use the cmdlet “Get-Member” to list the available methods.
    Besides, we can also find the documents about these methods and properties in MSDN:
    Workbook.Worksheets Property (Excel):
    http://msdn.microsoft.com/en-us/library/office/ff835542(v=office.15).aspx
    Worksheet.Shapes Property:
    http://msdn.microsoft.com/en-us/library/office/ff821817(v=office.15).aspx
    Shape.TextFrame Property:
    http://msdn.microsoft.com/en-us/library/office/ff839162(v=office.15).aspx
    TextFrame.Characters Method (Excel):
    http://msdn.microsoft.com/en-us/library/office/ff195027(v=office.15).aspx
    Characters.Text Property (Excel):
    http://msdn.microsoft.com/en-us/library/office/ff838596(v=office.15).aspx
    After running the script above, we can see the changes in the figure below:
    Figure 2.
    Please click to vote if the post helps you. This can be beneficial to other community members reading the thread.

    Thank you for the information, but does this thread really need to be stuck to the top of the forum?
    If there must be a sticky, I'd rather see a link to a page on the wiki that has links to all of these ForumFAQ posts.
    EDIT: I see this is no longer stuck to the top of the forum, thank you.
    Don't retire TechNet! -
    (Don't give up yet - 13,085+ strong and growing)

  • Find and Replace text string in HTML

    Opps... I hope this forum is not just for Outlook. My Html files reside on my hard-drive. I am looking for VBA code to open specified file names ####File.html and then find and replace text strings within the html for example "####Name" replaced
    with "YYYYY"
    I drive the "####File.html" names and the find and replace text strings from an Excel sheet. I am an artist and this Sub would give me time to paint instead of find and replace text. Thank you!
    [email protected]

    Hello Phil,
    The current forum is for developers and Outlook related programming questions. That's why I'd suggest hiring anybody for developing the code for you. You may find freelancers, for example. Try googling for any freelance-related web sites and asking such
    questions there.
    If you decide to develop an Outlook macro on your own, the
    Getting Started with VBA in Outlook 2010 article is a good place to start from.

  • How to find out if a string is all alphabets

    Hi,
    How can I find out if a string contains all alphabets? Please help. Thanks.

    Hi,
    How can I find out if a string contains all
    all alphabets? Please help. Thanks. I am not sure if there's easier way. But this code should do what you want:
    boolean bAlpha = true;
    for (int i=0; i<str.length; i++)
    if (!Character.isLetter(str.charAt(i))){
    bAlpha = false;
    break;
    //bAlpha is true if str contains only alphabets.

  • Is it possible to put some data, such as numeric and string, on the pront panel

    Hi guys,,,
    Is it possible to put some data,such as numeric or string as input data on the front panel? In general, I only know how to create text file by using notepad, for example,
    after that open and read that text file to show on the table control and plot XY graph. On the other hand, If I don't want to read the input data file from text file, I would like to use some tables in LabVIEW to serve as the input data instead of notepad, for example, on the front panel, and then take that input data table to plot XY graph afterwards. Is that possible?
    Thanks in advance
    Mannie

    There is a palette on the front panel if you right-click. It has controls on it that you can use as inputs and outputs. I've attached a picture.
    Also, you may want to run through Getting Started with LabVIEW. It covers things like this.
    (Edit: Oops, forgot the picture.)
    Message Edited by DJDDA on 12-10-2007 02:24 PM
    Attachments:
    controlspal1.gif ‏16 KB

  • Find first date of open FI periode

    Hi gurus!
    I want to check if the FI period is closed or not. If it is closed I want to find the open period, and then the first date in this period. How would you solve this?
    check if FI period is closed.
    If period is closed.
    - find open period.
    - find first date of open period.
    endif.
    <removed_by_moderator>
    Kind regards,
    Oyvind
    Edited by: Julius Bussche on Oct 27, 2008 12:22 PM

    use fm's FI_PERIOD_DETERMINE and PERIOD_CHECK
    use the result for first date:
    concatenate e_gjahr e_monat '01' into xdate.
    A.

  • Find first line in every column

    Hi All,
    Request:
    I want to find first line in every text frame column.
    Bug:
    If the active document contains single column, two column and multiple column text frames. In that case I am not able to get my result
    Trying script:
    var myDoc = app.activeDocument
    var myTextFrames = myDoc.textFrames.everyItem().getElements()
    for(i=0; i<myTextFrames.length; i++)
          var myTextColumns1 = myTextFrames[i].textColumns[1].lines[0].contents
              alert(myTextColumns1)
    Herewith i attached the error file.
    If active document contains only two column text frame, script run sucessfully.
    If active document contains single column text frame and two column text frame error found as below:
    Could anyone find solution for my request.
    Thanks in advance
    BEGINNER

    Try this,
    var myDoc = app.activeDocument
    var myTextFrames = myDoc.textFrames.everyItem().getElements()
    for(i=0; i<myTextFrames.length; i++)
        for(var j = 0;j<myTextFrames[i].textColumns.length;j++ )
            var myTextColumns1 = myTextFrames[i].textColumns[j].lines[0].contents
            $.writeln(myTextColumns1)

  • How to find and replace any string between " "

    Hi everyone,
    Here my sample
    String szTest;
    szTest = "Yellow banana";
    szTest = "Blue monkey";
    szTest = "Red mango";
    szTest is only needed when it's in testing progress. Now I want to put all of that in the /*comment*/ so the released program won't run those code any more (but still keep szTest so I can use it for future develop testing).
    So Here what I want after using the Find and Replace Box:
    //String szTest; //Manual
    /*szTest = "Yellow banana";*/ //use find and replace
    /*szTest = "Blue monkey";*/ //use find and replace
    /*szTest = "Red mango";*/ //use find and replace
    I think I can do this with Regular expressions or Wildcards. But I don't know how to find and replace any string between " and ".
    Find: szTest = " ??Any string?? ";
    Replace with: /*szTest = " ??Any string?? ";*/
    Thanks for reading.

    Hi Nathan.j.Smith,
    Based on your issue, I suggest you can try the Joel's suggestion check your issue again. In addition, I find a MSDN document about how to use the Regex.Replace Method to match a regular expression pattern with a specified replacement string,
    maybe you will get some useful message.
    https://msdn.microsoft.com/en-us/library/xwewhkd1(v=vs.110).aspx
    If the above suggestion still could not provide you, could you please tell me what language you use to create the program for finding and replace any string using regular expression so that we will find the correct programming develop forum to support this
    issue?
    Best Regards,
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Find first record in a set of record

    I want to find first record in a set of record .What built in function shall i use and which trigger should I use.Please help.

    Hi,
    First_record takes you to the position of that first record, but doesn't gives you the value of the record, you have to get it form the :block_name.item_name
    Jose.

  • Deciding whether value returned in NUMERIC or STRING.?

    I have a small query.
    I am reading values from differnt columns in a record.
    I have no idea which column contains a String value or which
    contains a numeric value.
    How do I check whether the value I receive is numeric
    My code is:
    myTable.getValueAt(int row,int col)
    Now here,I would like to check whether the value received is numeric
    or String
    if(myTable.getValue(0,0)) IS NUMERIC {..then do something....
    else if (myTable.getValue(0,0) =  "STRING" {
    }Any suggestions please? No offence

    Here's a general purpose function to see if a string "looks lke" a number://---------------------------------------------------------------------------
    * Determines if a string contains only digits, decimal points & hyphens.
    * @param string The string to check.
    * @return <code>True</code> if it has only digits, else <code>false</code>.
    * @since J2SE 1.4
    static public boolean isNumeric(String string)
       return string.matches("^[-+]?\\d+(\\.\\d+)?$");
    }However, it doesn't really tell you whether a string represents a number or not. That completely depends on how your program interprets it. For example, is a postal codde a number or a string? It has digits, but you wouldn't want to perform arithmetic on it.
    The issue of whether a string should be interpreteted as a number is more a design decision than a concern of the Java language. That's a long answer to the question. Hope it's intelligible.

Maybe you are looking for