Find Whether String Contain Sequence Of Character Or Not

<b>
hello friend,
I am to the new java. I need to findout whether the string contain sequence of character or not. I tried like this
personLastName.length()> 0
It will return true even my string contains space. Is there any other method in java to find out ?
Thanks

There are a few ways to do that. Check out the String class or Regex for one that suits but
myString.indexOf(whatIWantToFindString)is an old favorite. It returns -1 if the sequence is not there, or the starting index if it is. The javadocs are your friends.
regards

Similar Messages

  • Find if string contain letters

    HI All,
    How can I find if in string contain lettesr (in all the languages ),for instance
    if lv_string = '1a11'.
    subrc = 0.
    if lv_string = 'aaaa'.
    subrc = 0.
    if lv_string = '1111'.
    subrc = 4.
    Best regards
    Joy
    Moderator Message: FAQ. Thread locked.
    Edited by: Suhas Saha on Nov 17, 2011 5:40 PM

    There are a few ways to do that. Check out the String class or Regex for one that suits but
    myString.indexOf(whatIWantToFindString)is an old favorite. It returns -1 if the sequence is not there, or the starting index if it is. The javadocs are your friends.
    regards

  • How to Identify whether string contains only numbers

    Hi Experts,
    How to identify whether a string contains only numbers...
    Thanks & Regards,
    Neeraj.

    Hi Neeraj,
    ISNUMERIC(String_Field)
    The above function returns '0' for non-numerics and
    '1' for numeric
    Hope this helps.
    Regards,
    Bala

  • How to find whether PO is auto generated PO or not.

    Hi,
    How can we find the PO is Auto generated PO or Not in techinically.
    Appriciate quick response.
    Thanks & Regards,
    Surya Sankar

    Hi,
    You can check the following area.
    First check the T.code WE05 or BD87--> find the PO details if it has been created Automatically.
    Check in the BBP_PD and gets the details.
    Hope this will help you, award the points for the same.
    BR,
    Vijay Mittal

  • How check if a string contains a generic character?

    I want know how i can check if this string
    String mio= new String("Error 101");contains this substring
    1xxwhere "xx" are two generic characters that follow "1".
    Thanks
    Message was edited by:
    PremierITA

    Use a regular expression.Pattern threeDigitNumberThatStartsWith1 = Pattern.compile(".*1\\d\\d.*");
    Matcher matcher = pattern.matcher(mio);
    if(matcher.matches()) {
      // found it!
    else {
      // didn't find it
    }More about pattern matching here: http://java.sun.com/javase/6/docs/api/java/util/regex/Pattern.html

  • Best way to find a string contains a list of keywords

    Could anyone do any different or is this good enough?
    @ String line Line to be tested
    @ String keyline Line that contains comma delimited keywords
    private boolean containsAll(final String line, final String keyline) {
            int count = 0;
            String[] keywords = keyline.split(",");
            for (String keyword : keywords) {
                if (line.indexOf(keyword.trim()) != -1) {
                    count++;
            return count == keywords.length;
        }Is Regex faster?
    Thanks.

    geeflow wrote:
    Well! It looks that in my context the method needs to return FALSE if test string does not have ALL the items in the key word line. In my context, if keyword line = "", I run into trouble. That's an example of new requirements making the solution not good enough. Here's a way to incorporate splitting the keyword into the method, that should also eliminate the need for calling trim():
    private boolean containsAll(String line, String keyLine) {
        for (String keyword : keyLine.split("[, ]+")) {
            if (!line.contains(keyword)) return false;
        return true;
    } If line is empty, this will return false; no problem there. If keyLine is empty, you'll get a false positive. And if either one is null, you'll get a NullPointerException; you should probably check for those conditions first so you can throw a more helpful exception. You also have a case issue: "Double" is not the same as "double". You can get around that problem by using indexOfIgnoreCase() instead of contains().
    So I am still wondering if I can get away with not using a counter.Yes, you can--at least until the next time the requirements change. ;-)

  • To find whether the reports are in use or not for a given period

    Hi Basis Gurus,
    We have an requirement here that the client wants to know that the whether the reports for a given period are in use (working) or not.
    I think we can do it when we have audit logging activated ,but now we dont have audit logging activated now.
    Let me give you an example below
    Suppose for past 1 year 100 reports are prepared and out of 100 reports 95 reports are not working and remaining 5 reports are working.How can i get the detials from the SAP system without audit logging activated.
    Please help me
    Regards,
    Anil.

    Hello,
    See if ST03N helps you.
    Switch to expert mode in ST03N. Naviagate to Workload > Month > month . Click on the available month. Then in the " Analysis Views" visible on the lower LHS, Select transaction profiles > standard. See if you have your 'Z' report in that.
    Thanks and regards,
    Anish

  • A method which prints out if a strings starts with a character or not

    Below you can see what I have made :
    public class StringZerleger {
    public static void main(String args[]) throws Exception{
    new StringZerleger().zerlegeString();
    public void zerlegeString()
    String s3 = "_a b c d";
    String [] temp = null;
    temp = s3.split(" ");
    dump(temp);
    public void istGueltigerBezeichner()
    String s3 = String s3;
    boolean b = s3.regionMatches( 1, "_", 1, 1 );
    public void dump(String []s)
    System.out.println("------------");
    for (int i = 0 ; i < s.length ; i++)
    System.out.println(s);
    System.out.println("------------");
    unfortunately it doesn't work as I want it to work.
    Could someone help me please ?

    Below you can see what I have made :
    public class StringZerleger {
    public static void main(String args[]) throws
    Exception{
    new StringZerleger().zerlegeString();
    public void zerlegeString()
    String s3 = "_a b c d";
    String [] temp = null;
    temp = s3.split(" ");
    dump(temp);
    public void istGueltigerBezeichner()
    String s3 = String s3;
    boolean b = s3.regionMatches( 1, "_", 1, 1 );
    public void dump(String []s)
    System.out.println("------------");
    for (int i = 0 ; i < s.length ; i++)
    System.out.println(s);
    System.out.println("------------");
    unfortunately it doesn't work as I want it to work.
    Could someone help me please ?
    It shouldn't even compile.
    This method
    public void istGueltigerBezeichner()
    String s3 = String s3;
    boolean b = s3.regionMatches( 1, "_", 1, 1 );
    }1) is never called,
    2) should return a boolean
    3) should accept the string you are testing as a parameter
    4) should be redone using a different method of String
    private boolean istGueltigerBezeichner(String str)
    if(str == null)
        return false;
    return "_".equals(str.substring(0,1));
    }Then call this method from with you loop, before your println statement
    ~Tim
    Message was edited by:
    SomeoneElse

  • To find whether current user has SAP_ALL profile or not.

    Hi all,
    Can anyone tell me that whether is there any method by which I can pass the user id and can know whether that user has the SAP_ALL profile or not.
    The above is done by using the transaction SU01,but I need the ABAP code that is being used in this transaction.
    Regards,
    Varun.
    Message was edited by:
            Varun Bhandari

    Hi,
    Check table USR02 for the same.
    Regards,
    Ram

  • How to find whether the output file is generated or not?

    Hi,
    I ran EDI 855 program for one of our customer. The program succesfully completed and it shows in the logfile that few documents got processed and few lines got processed. But the output file in the outbound directory shows the file size as zero.
    Can anyone please let me know what could be the problem.
    And please let me know how to check whether flatfile is generated succesfully for the request run for any customer.
    Thanks in advance.
    Satya

    Hi Venkat,
    As every one have already explained other points,in standard SAP there is no provision to determine as if the sales order is intercompany or not.
    But if you  want you can create a user status as normal sales order and intercompany sales order.So by checking the status at table level or in order you can determine if it is Intercompany or normal sales order.
    Best way is to create a different document type itself which will be exclusively used for intercompany orders.So it will be easy for reporting and tracking purpose.
    Reward points if useful
    Regards,
    Amrish Purohit

  • How to find whether the sales order is intercompany or not?

    Hi guys,
    I created a sales order. In that i changed the plant which is there in other company code. so it bcomes like a intercompany sales order. but the problem is if i go to change mode how can I findout it as intercompany sales order.
    thanks & regards.
    venkat

    Hi Venkat,
    As every one have already explained other points,in standard SAP there is no provision to determine as if the sales order is intercompany or not.
    But if you  want you can create a user status as normal sales order and intercompany sales order.So by checking the status at table level or in order you can determine if it is Intercompany or normal sales order.
    Best way is to create a different document type itself which will be exclusively used for intercompany orders.So it will be easy for reporting and tracking purpose.
    Reward points if useful
    Regards,
    Amrish Purohit

  • Quick string question finding if a string contains a character

    hello peeps
    is there a quick way of checking if a string contains a specific character
    e.g.
    myString="test:test";
    myString.contains(":");
    would be true
    any ideas on a quick way of doing it

    is there a contains() method in 1.4.2? i couldnt see
    it in the docsNo there isn't. But the 1.5 has a contains(CharSequence s) method.

  • String contains special chars

    Hi there,
    If given string contains a special character in the first position..i need to delete the character from the string.
    please suggest a way..

    It's clunky, but try this:
    To replace special character with space.
    data:  w_val type string.
    move old_string+0(1) to w_val.
    replace first occurance of w_val in old_string with space.
    OR
    To remove it entirely
    shift old_string by 1 places left.    " Shifts string to left and drops off characters to left.
    Steve

  • Finding whether the user has administrative rights

    Is there any way by which we can find whether the user has administrative rights or not using java?

    The very notion of "administrative rights" is
    platform-dependent. It's not standard or well-defined
    what "administrative rights" means across all OSes.
    You'll have to use JNI or Runtime.execI searched net a lot but couldnt find any tutorial or artical regarding how to achieve this in C or C++.
    Any link will be helpful.

  • How to find out whether the String contains chinese characters

    I need to check if the string contains chinese characters in Java. Does anyone know how to do it? thx.

    Since Java strings contain UNICODE code points, check the content against the relevant page here - http://www.unicode.org/charts/ .

Maybe you are looking for

  • Deploying SQLJ classes as Java Stored Procedures using JDeveloper 10g

    Hello, I have defined a SQLJ class, MwaSqljDao.sqlj, in JDeveloper. When I right click on the SQLJ class and "make" the class. It appears to succeed. However when I attempt to build the project in which the SQLJ class is a member of, a class that use

  • Conditional Form Fields in a Survey

    I am putting together our employee satisfaction survey and need some help.  Employees will be asked to tell us how to satisfied they are with some aspects of  the company. For example: Question 1: Cost of health insurance for  employees and families

  • Why is the "streaming' Adobe Photoshop only for students on Chrome OS or  WIndows?

    Considering Adobe hasn't acknowledged the Linux crowd that has been petitioning for a port for years, the announcement of "streaming' Adobe Photoshop for only students on Chrome OS or  Windows doesn't surprise me in the least.  Is this a beta only de

  • Regarding Tcode

    Hi Abapers,    Please tell me the Transaction code to upload data in Table T023 (Master-Material Group Creation) Regards Sundar

  • Problem updating file

    Hi -- I have a .dir file that was created around 2003. I need to re-create it as a Flash file, so I downloaded a copy of Director 11.5. When I try to open the file, I get a window to upgrade the file.  After I select the backup location, I get an err