How to test if String starts with a Range of numbers

Hello,
I'm reading in a line from a text file and I want to see if that line starts with numbers.
I know there is
String temp = file.readline();
if (String temp.startsWith(?1-9?); // want to check if string starts with 1 thru 9
Thanks!

Try the following:
String temp = file.readline();
if (temp.equals("1") || temp.equals("2")....... || temp.equals("9") {
System.out.println("String is beetween 1 - 9");
else{
System.out.println("String is not beetween 1 - 9");
Replace the "....." by the other values... I know it's quite long, but it should work... must be an easier way though...
Pierre

Similar Messages

  • Regular expression matches string starts with &

    Hello,
    I am trying to write a Reg Exp that removes any string starts with "&" and Ends with ";" . In other words, I am trying to remove anything similar to:
    & nbsp;  & quot; & lt; & gt;  Any help please.
    This does not work:
    select regexp_replace(ename, '^&[a-z]{2,4}[;]$') from emp;Regards,
    Fateh

    Fateh wrote:
    I am trying to write a Reg Exp that removes any string starts with "&" and Ends with ";" . In other words, I am trying to remove anything similar to:
    & nbsp;  & quot; & lt; & gt; 
    Those are entity references (without the whitespace after '&').
    Do you really want to remove them, or do you actually want to convert them back to their corresponding characters but don't know how to do it?
    SQL> set scan off
    SQL> select utl_i18n.unescape_reference('"Test": 3>2') from dual;
    UTL_I18N.UNESCAPE_REFERENCE('&
    "Test": 3>2

  • String "starts with" function in ABAP

    Hi!
    I need to check in ABAP, if a given profit center (char 10) starts with P172. It could be filled with zeros -> 0000P17255. So I need to perform 2 actions:
    1)
    Lefttrim the 0 -> Result: P17255.
    2)
    Check, if the string starts with P172.
    How can I do this in ABAP?
    Thanks,
    Konrad

    Hi,
    You can do as below :
    1st scenario :
    loop at itab.
    "Below code will delete leading zero.
    SHIFT itab-prctr LEFT DELETING LEADING '0'.
    "Second scenario
    if itab-prctr(4) = 'P1972'.
    "Do necessary coding as per your requirment.
    endif.
    "If you wnat chnage tje contensts of the itab you can use modify else you append to append to another internal table.
    endloop.
    Thanks,
    Sriram POnna

  • How can I make textedit start with a new (blank) document?

    How can I make textedit start with a new (blank) document?
    Instead of it starting up with a dialogue box to select an existing or start a new document.

    @Alley_Cat thanks for the ideas.
    I turned off System Preferences > iCloud > Documents&Data - problem solved.
    I'll use DropBox instead  - it provides the options for a better experience.  I hope Apple keep working on iCloud so that it doesn't go the way of Moble Me.

  • How to return all columns starting with E?

    How to return all columns starting with E in emp table?
    My attempts (below) were unsuccessful.
    SQL> SELECT E* from emp;
    SELECT E* from emp
    ERROR at line 1:
    ORA-00936: missing expression
    SQL> SELECT E.* FROM EMP;
    SELECT E.* FROM EMP
    ERROR at line 1:
    ORA-00904: "E": invalid identifier
    SQL> SELECT EMP.E* FROM EMP;
    SELECT EMP.E* FROM EMP
    ERROR at line 1:
    ORA-00936: missing expression

    You need to do it dynamically:
    SQL>  var cur refcursor
    SQL>  declare
      co varchar2(40);
    begin
      for c in (select column_name from cols where table_name = 'EMP' and column_name like 'E%') loop
        co := co || c.column_name || ',';
      end loop;
      open :cur for 'select '|| rtrim(co,',') || ' from emp';
    end;
    PL/SQL procedure successfully completed.
    SQL>  print cur
         EMPNO ENAME    
          7369 SMITH    
          7499 ALLEN    
          7521 WARD     
          7566 JONES    
          7654 MARTIN   
          7698 BLAKE    
          7782 CLARK    
          7788 SCOTT    
          7839 KING     
          7844 TURNER   
          7876 ADAMS    
          7900 JAMES    
          7902 FORD     
          7934 MILLER   
    14 rows selected.

  • How do I add strings together with JSTL?

    How do I add strings together with JSTL?
    Thanks,
    JN

    Just include them together in an expression string.
    For printing
    <c:out value="${user.lastName}, ${user.firstName}"/>
    or with a set statement
    <c:set var="fullName" value="${user.lastName}, ${user.firstName}"/>

  • How do I cerate an array with a set of numbers lets say 1 through 12 random order but no repeating.

    How do I cerate  an
    array with a set of numbers lets say 1 through 12 random order but no
    repeating.
    I know this should be easy but my brain wont work
    right now
    Solved!
    Go to Solution.

    OK, here's the handmade version.
    It is useful to know that arrays of clusters are sorted by the cluster order of the elements. Simply bundle random numbers with numbers 1-12 in a loop, create an array at the output tunnel, sort the array by the random number, and extract the number array. It will be shuffled.
    Message Edited by altenbach on 06-04-2007 09:20 PM
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    shuffleArray.png ‏5 KB

  • Extracting a  a piece of string starting with a number

    Hi,
    I am new to SQL, so I could use some help with the following issue. I need to extract contract number from a string, but the position of the contract number and the text inside of the string might vary, which means it is important to tie the SELECT statement to the number. Extracting only numbers wouldn't help too, because contract number contains letters and other characters. For example, if there was a string "Payment to a contract nr 1100/70HE", the SELECT statement should be able to extract only "1100/70HE" from that string.
    Thank you in advance,
    Keit

    Hi,
    welcome to the forum.
    Please read SQL and PL/SQL FAQ
    When you put some code or output please enclose it between two lines starting with {noformat}{noformat}
    i.e.:
    {noformat}{noformat}
    SELECT ...
    {noformat}{noformat}
    Coming to your question, I would say that extracting the contract number from a string it is not the ideal solution for a data model.
    Beside that, you may be able to reach your goal by using regular expression but you should provide more example and explain if the contract number could be identified with a specific pattern.
    I suggest you to post some sample data (CREATE TABLE and INSERT statement or a WITH statement) and try to identify a rule that can apply to extract your data.
    I.e.: if contract number always is one or more characters, followed by a slash (/) and followed by one or more characters then maybe you can use regular expression to identify it. I suggest you to post some cases and try to find the logic to apply.
    Regards.
    Al                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • How to set a string field with people picker control group

    Hi Guys
    I have a problem with a form list, when I need to set a string field with de content of people picker control that have more than one "user".
    Is there any way to put in string a list of user like the people picker control shows in a form?
    The really problem is I don't know how to read an array of user in a formula rule.
    any example or idea should be appreciated.
    tnks.

    Hi ,
    Please try out in following way :
            /// <summary>
            /// Set value to people picket control
            /// </summary>
            /// <param name="key"></param>
            /// <param name="ppl"></param>
            /// <param name="item"></param>
            private void SetDatatoPeopleEditor(string key, PeopleEditor ppl, SPListItem item)
                try
                    if (item[key] != null)
                        string users = string.Empty;
                        SPFieldUserValueCollection userCol = new SPFieldUserValueCollection(web, item[item.Fields.GetField(key).Id].ToString());
                        foreach (SPFieldUserValue usrItm in userCol)
                            users += usrItm.User.ToString() + ",";
                        ppl.CommaSeparatedAccounts = users.Remove(users.LastIndexOf(","), 1);
                catch (Exception ex)
                    lblErrorMessage.Text = ex.Message;
    private SPUser GetAccountName(PeopleEditor accountPE)
                SPUser user = null;
                string strAccountName = String.Empty;
                try
                    for (int i = 0; i < accountPE.ResolvedEntities.Count; i++)
                        PickerEntity objEntity = (PickerEntity)accountPE.ResolvedEntities[i];
                        user = web.AllUsers[objEntity.Key];
                    return user;
                catch (Exception ex)
                return user;
    It works for me .

  • How to use SQL filtercondition 'Start with' and 'connect by' in ADF's LOV?

    Hello every!
    I can not use 'Start with' and 'connect by' with parameter in creating ADF's LOV?
    How could I do with it?
    Alex

    assuming you are using adf 11g,
    You need to use View Criteria with the View Object attribute that has a LOV model.
    Follow this, to get some idea http://andrejusb.blogspot.com/2008/12/cascading-lovs-in-oracle-adf-11g-update.html
    hope this helps,

  • How do I show files starting with a "." in my Mac?

    Hello fellow Apple users, I have a problem here. Care for a bit of help?
    I am using: OS X Mavericks Version 10.9.4, Macbook-Pro With Retina Display 13'', bought in mid 2014.
    I seem to have a problem with revealing hidden files on my Mac, as I am currently creating a modification for a game called "Minecraft" using Eclipse. Every time I try to open my project, it says that the .project file for the project is missing, how do I solve this?
    Is there a way to make files starting with a "." appear, and to applications as well? (And yes, I know how you can do "defaults write blah blah blah...' in the Terminal, but it still won't just work for Eclipse, even if it works for us.
    Thanks in advance,
    Alex Ni

    Revealing hidden files and getting that error are 2 completely different thing. Even though you can't see hidden files in a finder window doesn't mean they are inaccessible to programs and the OS. They are just hidden from view to the user.

  • How to select number field starting with 99

    Hi Freinds-
    I have to pick values for a number field  but  i want only those values which starting with 99 
    how i can put code in select query for this ?
    Regards
    Meeta & Ruby

    Hi,
    Use the query as:-
    select
       <field1>
       <field2>
    from <database_table>
    into table <internal_table>
    where
       <field_name> like '99%'.
    Hope this solves your problem.
    Thanks & Regards,
    Tarun Gambhir

  • How to select rows which starts with

    In the below example I want only the rows which starts with the word CERTIFICATE.
    How do we do?
    create table full_text(text clob);
    insert all
    into full_text values('CERTIFICATE OF SERVICE')
    into full_text values('APPLICATION FOR CERTIFICATE')
    into full_text values('CERTIFICATE OF LIABILITY')
    into full_text values('CERTIFICATE OF TITLE')
    SELECT * FROM DUAL ;
    COMMIT;
    CREATE INDEX CTX_INDX_TEXT ON full_text (TEXT) INDEXTYPE IS CTXSYS.CONTEXT;
    SQL> select * from full_text where contains(text,'$CERTIFICATE')>0 ;
    TEXT
    CERTIFICATE OF TITLE
    CERTIFICATE OF LIABILITY
    APPLICATION FOR CERTIFICATE
    CERTIFICATE OF SERVICE
    The 3rd row show not appear.
    Thanks

    I understand what Roger is saying. Since it is past his bedtime there in the UK and still sunny here in California, here is an example for you:
    SCOTT@orcl_11g> create table full_text(text clob)
      2  /
    Table created.
    SCOTT@orcl_11g> insert all
      2  into full_text values('CERTIFICATE OF SERVICE')
      3  into full_text values('APPLICATION FOR CERTIFICATE')
      4  into full_text values('CERTIFICATE OF LIABILITY')
      5  into full_text values('CERTIFICATE OF TITLE')
      6  SELECT * FROM DUAL
      7  /
    4 rows created.
    SCOTT@orcl_11g> CREATE OR REPLACE PROCEDURE your_proc
      2    (p_rowid IN           ROWID,
      3       p_clob     IN OUT NOCOPY CLOB)
      4  AS
      5  BEGIN
      6    FOR r IN
      7        (SELECT text
      8         FROM      full_text
      9         WHERE  ROWID = p_rowid)
    10    LOOP
    11        DBMS_LOB.WRITEAPPEND (p_clob, 8, 'XXSTART ');
    12        DBMS_LOB.APPEND (p_clob, r.text);
    13        DBMS_LOB.WRITEAPPEND (p_clob, 6, ' XXEND');
    14    END LOOP;
    15  END your_proc;
    16  /
    Procedure created.
    SCOTT@orcl_11g> SHOW ERRORS
    No errors.
    SCOTT@orcl_11g> BEGIN
      2    CTX_DDL.CREATE_PREFERENCE ('your_datastore', 'USER_DATASTORE');
      3    CTX_DDL.SET_ATTRIBUTE ('your_datastore', 'PROCEDURE', 'your_proc');
      4    CTX_DDL.SET_ATTRIBUTE ('your_datastore', 'OUTPUT_TYPE', 'CLOB');
      5  END;
      6  /
    PL/SQL procedure successfully completed.
    SCOTT@orcl_11g> CREATE INDEX CTX_INDX_TEXT ON full_text (TEXT) INDEXTYPE IS CTXSYS.CONTEXT
      2  PARAMETERS ('DATASTORE your_datastore')
      3  /
    Index created.
    SCOTT@orcl_11g> select * from full_text where contains(text,'XXSTART $CERTIFICATE')>0
      2  /
    TEXT
    CERTIFICATE OF SERVICE
    CERTIFICATE OF LIABILITY
    CERTIFICATE OF TITLE
    SCOTT@orcl_11g>

  • How do I make firefox start with previous session tabs open by default?

    I basically want Frefox to start with the same tabs and URL locations as they were when I previously closed Firefox.

    Click the Firefox menu button or Edit in the classic menu, then select Preferences, select the General tab, and under the Startup heading select "Show my windows and tabs from last time".

  • How to make time stamp start with 00:00 ?

    Hi,, everybody,
    I want to make the time stamp of Minec
    but must start with 00:00 and when I start the acquisision the time increase. (Function looks like the sport clock)
    I take a look in Labview, it has only time stamp with the current time.
    Thanks for any kind help in advance.

    Hello,
    there are 3 links to your issue, which should answer your question.
    http://pong.ni.com/public.nsf/websearch/0A4899EF6D01B9C5862568B70074F989?OpenDocument
    http://exchange.ni.com/servlet/ProcessRequest?RHIVEID=101&RNAME=ViewQuestion&HOID=50650000000800000088410000&ECategory=LabVIEW.LabVIEW+General
    http://sine.ni.com/apps/we/niepd_web_display.display_epd4?p_guid=B123AE0CBB5D111EE034080020E74861&p_node=DZ52026
    Regards
    Thomas D.
    NI Germany
    (SRQ 199423)

Maybe you are looking for