String alphabetical checking / validation

Hi
I am wanting to check that a String is only composed of alphabetical characters or spaces. Is there a nice API in the JDK that I can use to check / validate this String?
Thanks

tinny wrote:
Regular expressions are the nice way to do it.
The code below will check to see if a String is composed of any combination of alphabetical characters or spaces.
String str = "Hello from me";
boolean result = Pattern.matches("[a-zA-Z ]+", str);result =trueNote that the ' ' (single white space) in your "[a-zA-Z ]" will not match tabs or other white space characters. If you also want them to match, you can use:
"[a-zA-Z\\s]+"
//   \\s means (almost) any white space character

Similar Messages

  • EBS search string for check number

    Hello Gurus
    My client is using MT940 FORMAT for EBS,requirement is in a bank statement we are having 10 transactions which are having the same amount for ex:rs.1000 for ten payment transactions. now system is not able to post the document when we import the bank statement.
    I wanted to use search string for check number,  note to payee in bank statement is check number.Please find the below refference
    /EI/400229001       010013
    0000010013
    Reference 010013
    How could i use search string for this i tried but im not getting the solution im getting the following error difference is too large F5 263.
    Appreciated for our help............
    Thanks a lot in advance...............

    Hi Paulo,
    Thanks for the reply. However i have the following setting and it still does not work..
    Mapping -> AB01
    When i do the simulation it shows the Number and the hits and mapping.
    In the Seach String use i have following settings:
    CC 1000
    Interpretation : ALL Interpretation
    Search String : TEST1 ( this is the name that i gave to above search string)
    Target : Posting RUle
    Active checked.
    But still when i upload the bank statement it is posting to Rule AB03 and not AB01
    Also when i try FEBSTS it says no document hits ???
    Your answer is greatly appreciated.

  • How to determine if string represents a valid numeric

    Using Labview (6.1), what is the easiest way to determine if a string represents a valid numeric?

    Try using the "Scan From String" function on the string palette. Using
    a format specifier of "%f" or "%d" will try to format the string into a
    number. If the string contains anything besides numbers, the function
    should generate an error.
    Ed
    Message Edited by Ed Dickens on 10-03-2005 03:03 PM
    Ed Dickens - Certified LabVIEW Architect - DISTek Integration, Inc. - NI Certified Alliance Partner
    Using the Abort button to stop your VI is like using a tree to stop your car. It works, but there may be consequences.
    Attachments:
    scan from string.gif ‏3 KB

  • The time string has a valid format but it corresponds to the future time

    First all, I want to thank richwolf ... without his Woolamaloo.. I don't know if I can every have this to work---> for a person that is not a programmer, that application really helps a lot.
    When I use the debug function in Woolamaloo, it gave me the information about that time string has a valid format but it corresponds to the future time. And, because of that only "all" access is allowed.
    If we can't change the server time setting, is there any way I can modify the script to correct this? I place the modified itunesu (from the apple sample code, shell folder) file to the cgi-bin folder on the server. Any help will be really appreciated thank you all.
    Trouble R.

    First of all, thank you for using Woolamaloo. You are too kind.
    The time token is used to create your signature token ... and you need the signature to have a valid token string. So I can't see a way for you to do what you ask.
    Is there any way you can use the server that you don't control to do authentication only ... and generate the token string on a server whose time you can set?

  • Sort Characters of String - Alphabetically

    HOw to sort the Characters of a String Alphabetical order.
    looking for the algorithm
    if the String is "SAMPLE" (String s = "SAMPLE")
    need to get the answer as "AELMPS"
    Message was edited by:
    jugp

    try converting the string to an array of the letters, sort the array, and then convert the sorted array back into a string. you should be able to figure out the rest. Look at the API for String for the methods you need.
    ~Tim

  • Can i turn a series of integers such as 1000-1200  into a string to check

    can i turn a series of integers such as 1000-1200 into a string to check positions with charAt I need to scan numers 1000-9999 to add the digits 1+0+0+0=1 or 9+9+9+9=36 to find the ones that when the result ie 36 is rased to the 4th power equal the original number? I want to scan charAt(position) then add those 4 positions.please help me
    heres my code so farpublic class Poweroffour
        public static void main(String[] args)
        int number;     
         String numberS;
        int numtotal;
         int numtotalpoweroffour;
         int num1;
         int num2;
         int num3;
         int num4;
         for (number=1000;number<10000;number++)
              numberS=number;
              num1=numberS.charAt(1);
              num2=numberS.charAt(2);
              num3=numberS.charAt(3);
              num4=numberS.charAt(4);
                 numtotal=num1+num2+num3+num4;
                 numtotalpoweroffour=numtotal*numtotal*numtotal*numtotal;
                 if (numtotalpoweroffour==number)
                      System.out.println(number);
        }}

    public class Poweroffour
        public static void main(String[] args)
            int numb=0;
             int thou=0;
            int hund=0;
            int tens=0;
            int ones=0;
            int total;
            int count;
           for (numb=1000;numb<10000;numb++)
                thou = numb/1000;
                hund = (numb -(thou *1000))/100;
                tens = ((numb % 100)- ones)/10;
                ones = numb % 10;
                System.out.println( thou + " " + hund + " " + tens + " " + ones);
    }          

  • Can Check Valid From task be run on multiple JVMs in clustered env.

    The configuration screen for the Check Valid From scheduler task allows it to be run oin more than one JVM in a clustered environment.
    Has anyone done this?
    Does this cause any problems?

    Hello Timothy,
    This is not recommended for any scheduler task as it potentially means that the task could be run multiple times and would most likely lead to inconsistencies in the results of the task. Have a look at SAP note 798633 which discussed this a little more.
    Regards,
    Lorcan.

  • String Language Checking

    Hi,
    what is the best way to check that a certain string matchs a certain language, for example i have user input name (String) where i need to validate that its Arabic, is it recommended to use the uni-code ranges checking, or is there a better way of doing so.
    Thanks in advance

    That question has been asked tons of times.
    Mostly you are out of luck.
    Using Unicode ranges you can check the script at best. And usually several languages share a script (many western languages share the Latin script, for example).
    If you had more data about each language you need to identify (for example a complete dictionary of each language), then you could do a more in-depth analysis to find out which language it probably is. This can get hard (and even impossible) if the text you need to identify is short (just guess in how many languages "a" is a valid word).

  • Given String Date is valid/not?

    Hi Friends,
    I am getting date in string format e.g.
              String creationDate = "2007/02/30";
    I want to check is valid or not. see in the example I have given 30 Feb 2007 which is invalid date. Is there any way to check the date is valid or not.
    Any help will be appreciable for me.
    Thanks in advance...
    - Hiren Modi

    use the java.text.SimpleDateFormat. The strategy is to instanstiate a SimpleDateFormat with the date pattern and then parse the input string with it to produce a java.util.Date. This in turn is fed back in the same SimpleDateFormat instance for formatting resulting in a String which is then compared to the input string. If they are not equal then the input string is an invalid date. something like
    String input = "2007/02/30";
            String output = null;
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd");
            try {
                Date date = sdf.parse(input);
                output = sdf.format(date);
                if (!input.equals(output)) throw new IllegalArgumentException("invalid date");  // or however you want to handle it
            } catch (ParseException ex) {
                ex.printStackTrace();
            }

  • How to check validation for a input field?

    For example, I need to check the validation of a field, if OK, then the field will be inputted, otherwise, there will rise a message, how can I implement that?
    Thanks and best regards,
    Anders

    Hi Andres,
    U can write a code in Request Processing--DO_VALIDATE_INPUT
    DATA: LR_BTADMINH       TYPE REF TO   CL_CRM_BOL_ENTITY.
      LR_BTADMINH  ?= ME->TYPED_CONTEXT->BTADMINH->COLLECTION_WRAPPER->GET_CURRENT( ).
        LV_ZZAFLD000057 = LR_ENTITY->GET_PROPERTY_AS_STRING( 'ZZAFLD000057' ).
    IF  LV_ZZAFLD000057 IS INITIAL.
    DATA: L7_MSG_SERVICE TYPE REF TO CL_BSP_WD_MESSAGE_SERVICE,
              LVSP_MSG_V1  TYPE STRING VALUE 'Spare in Progress'.
        L7_MSG_SERVICE = ME->VIEW_MANAGER->GET_MESSAGE_SERVICE( ).
        L7_MSG_SERVICE->ADD_MESSAGE(
            IV_MSG_TYPE       = 'E'
            IV_MSG_ID         = 'ZBSP'
            IV_MSG_NUMBER     = '008'
            IV_MSG_V1         = LVSP_MSG_V1 ).
    ENDIF.
    Regards,
    Lokesh.

  • Checking/Validating user input in a text field

    How can I validate a user's input in a text field and require them to input it in the following format:
    AAA 9999-999
    (where A can be letters and 9 can be numbers)
    Is there any documentation on how to validate user inputs in this manner?
    Thanks!
    BoilerUP

    Hi,
    Create a validation PL/SQL process, select Function returning Error and use something similar to the example below.
    I tested it but may be I missed something. I used field name P1_TEST.
    DECLARE
    v_number NUMBER;
    v_error VARCHAR2(1000);
    BEGIN
    --check if you have numbers in positions 5-8 and 10-12
    v_number:=SUBSTR(:P1_TEST,5,4);
    v_number:=SUBSTR(:P1_TEST,10);
    --check string length
    IF LENGTH(:P1_TEST)!=12 THEN
    RETURN 'String length must be 12 characters';
    END IF;
    --check if position 4 is empty
    IF INSTR(SUBSTR(:P1_TEST,4,1),' ')=0 THEN
    RETURN 'There should be a space between letters and numbers';
    END IF;
    --check if position 9 has "-"
    IF INSTR(SUBSTR(:P1_TEST,9,1),'-')=0 THEN
    RETURN 'There should be a dash between numbers';
    END IF;
    --check if positions 1-3 has letters
    FOR i IN 1 .. 3 LOOP
    SELECT ascii(substr(:P1_TEST, i, 1)) INTO v_number
    FROM Dual;
    IF v_number>=48 AND v_number<=59 THEN
    RETURN 'Only letters are allowed in positions 1,2,3';
    END IF;
    END LOOP;
    RETURN NULL;
    EXCEPTION
    WHEN OTHERS THEN
    v_error:=SQLERRM;
    IF INSTR(v_error, 'ORA-06502')>0 THEN
    RETURN '...must be integers only';
    ELSE
    RETURN v_error;
    END IF;
    END;
    I hope it will give you an idea on this type of validation.
    Val

  • How can I display an icon, instead of text string, as a validation prompt?

    My validate method inside my custom validator is like this:
    public void validate(FacesContext context, UIComponent component, Object value) {
      Pattern datePattern = Pattern.compile("(\\d{2})/(\\d{2})/(\\d{4})");
      Matcher dateMatcher = datePattern.matcher((String)value);
      if(!dateMatcher.find()){
        ((UIInput)component).setValid(false);
        FacesMessage message = new FacesMessage();
        String msg = "[" + value + "] invalid date";
        message.setDetail(msg);
        context.addMessage(component.getClientId(context), message);
        FacesMessage facesMsg = new FacesMessage(FacesMessage.SEVERITY_FATAL, "xx", "msg");
        throw new ValidatorException(facesMsg);
    }My JSP has this:
    <h:inputText id="test" value="#{projecthandler.test}">
    <f:validator validatorId="DateValidator" />
    </h:inputText>
    <h:message id="testErrorMessage" for="test"/>The <h:message> tag will kick in if the user has invalid data in the <h:inputText> field and clicks submit.
    When the page is regenerated, the user will see a text string reflecting what the issue is.
    However, instead of this, I would like to display an icon consisting of a red circle with an exclamation point.
    The user is supposed to click on the icon if they want more information. By clicking on the icon,
    the user will see a message box, with a description of the error.
    This is our standard for applications. I'm trying to put together a demo showing how an existing application
    would work in JSF, so I won't be able to talk others into using JSF, unless I can get the validation to display an
    icon instead of text.
    Edited by: Kazan on Mar 18, 2009 9:31 AM
    Edited by: Kazan on Mar 18, 2009 9:33 AM
    Edited by: Kazan on Mar 18, 2009 9:36 AM

    OK, I noticed a bug in my validate method. This is updated to fix the bug, and to include the recomendation about background-image:
      public void validate(FacesContext context, UIComponent component, Object value) {
        System.out.println("DateValidator.test.1");
        Pattern datePattern = Pattern.compile("(\\d{2})/(\\d{2})/(\\d{4})");
        Matcher dateMatcher = datePattern.matcher((String)value);
        System.out.println("DateValidator.test.1");
        if(!dateMatcher.find()){
          ((UIInput)component).setValid(false);
          FacesMessage message = new FacesMessage();
          String msg = "<span style='background-image: url(/error.gif)'/>";
          message.setDetail(msg);
          message.setSeverity(FacesMessage.SEVERITY_FATAL);
          context.addMessage(component.getClientId(context), message);
          throw new ValidatorException(message);
      }When I run this, the litteral string of "<span style='background-image: url(/error.gif)'/>" is printed as the message. It does not interpret this as a span tag with an image url.
    Can someone tell me what's going on?

  • How to check validity of data reference

    Hello everybody,
    in my application I use a help class to buffer data objects.
    This class contains one attribute which is an internal table ( columns: DATAID and DATAREF )
    I use this databuffer to transport data between different classes.
    Now I did the following mistake:
    First I call the method 'METH_CHECK'. As import parameter I pass a reference to my databuffer class.
    In method 'METH_CHECK' I call a function module 'FUNC_1' passing my reference to my databuffer class.
    In 'FUNC_1'  I declare a local variable 'lv_value'.
    Then I use the statement 'GET REFERENCE OF lv_value' and save this reference into my databuffer class.
    After processing functions / methods I´m back at the point where 'METH_CHECK' was called.
    When I check my databuffer class, I´ve got one entry in it.
    The reference I saved while processing 'FUNC_1' . But the referenced data has already be freed ( remember, it was a local variable ).
    In the debugger I see the column where I save the references to data objects.
    The field value has changed from a valid reference to i.e. 'FREED ITAB: 5'...
    OK, I know what is wrong... No problem in my application, but I want to clean
    this entry... How can I check this...
    I can not check like
      LOOP AT me->buffer INTO wa_buffer.
        IF wa_buffer-data IS INITIAL.
          DELETE...
        ENDIF.
      ENDLOOP.
    or
      LOOP AT me->buffer INTO wa_buffer.
        IF wa_buffer-data CP 'FREED'.
          DELETE....
        ENDIF.
      ENDLOOP.
    How can I notice an invalid reference at this point?
    Thank you very much,
    Oliver Seifer

    Hello Oliver,
    Another approach might be to avoid any dependency to the caller at all.
    Regards
      Klaus
    data:
        buffer_Reference  type ref to data.
    field-symbols:
       <buffer_Data> type data.
    create data buffer_Reference like i_Value.
    assign buffer_Reference to <buffer_Data>.
    <buffer_Data> = i_Value.

  • How to ReUse Existence Check Validation ?

    Hi All,
    I read chapter 9.6.2 of ADF Developer Guide 4GL, "9.6.2 Implementing an Efficient Existence Check". However the exists() method in the ProductDefImpl.java can only be use to check product existence when user add new product on Product entity .
    But in my case, there are many entities having FK referring to Product
    entity, e.g :
    OrdersDetail has FK to Product
    PurchaseDetail has FK to Product
    ShipmentDetail has FK to Product
    ..and some more...
    I don't want to code productExists() method to all xxxDefImpl class of all
    above entities. How can I create just one productExists() method and reuse it in all entities having FK to Product entity ?
    Thank you for your help,
    xtanto

    Hi Steve,
    yes, I have check to ServiceRequestImpl in SRDemo, there is a method validator that invoke productDef.exists(getDBTransaction(),data).
    But, by using method validator, I still have to copy-paste the code to ALL entities that has FK to Product.
    How to make it a Reusable Validation Rule (like "DateMustComeAfterRule") so that I just need "plug" it to All entities (at attribute level) having FK to Product ?
    Thank you,
    xtanto

  • Check validation of WBS and AGENT at SC level instead of PO creation time.

    Hi all,
            is there any function module to check the issues with the account assignment like agents are missing for cost center or WBS for a shopping cart , this is validated during PO creation but my requirement is to validate it during the SC Cart creation .
    Thanks
    Aditya

    Hi Adidya
    You are correct. Indeed all checks happen during PO only not through SC.
    You can use DOC check badi only
    How to get  blocked cost centers in SRM from ECC(Table CSKS(
    http://wiki.sdn.sap.com/wiki/display/SRM/META_READ_TABLE
    BR
    Muthu

Maybe you are looking for

  • File - convert - xslt 1.0 disabled

    Hello all, How can i enable file -> convert -> xslt 1.0 in dreamweaver 8? Thanks in advance, Carest

  • Why do my CD drives open at startup?

    Lately my CD/DVD drives open at startup and close about a minute later.  I have no idea why this started.  How can I disable this? Thanks, Jim

  • CHANGES IN VALID SIGNATURE OF main() ?

    Hello! I have the version 1.2.2 of java. Have done some tests with the method main () and has found that already compiles and runs with the modifiers: private, protected, final, or synchronized. Can also be default (friendly). Someone it is able to s

  • Starting Safari with command-line options

    I am an old Unix Hacker who just started with Mac. Since scripting is an important part of old-school UNIX, I do many things via scripting. My question is: Is there a way to start Safari from the command line using command-line options that will allo

  • How do u unlock the phone when you forget your password

    We can not remember the password & have been locked out of the phone. How do I unlock it?