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

Similar Messages

  • 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

  • Unique regular expression to check if a string contains letters and numbers

    Hi all,
    How can I verify if a string contains numbers AND letters using a regular expression only?
    I can do that with using 3 different expressions ([0-9],[a-z],[A-Z]) but is there a unique regular expression to do that?
    Thanks all

    Darin.K wrote:
    Missed the requirements:
    single regex:
    ^([[:alpha:]]+[[:digit:]]+|[[:digit:]]+[[:alpha:]])[[:alnum:]]*$
    You either have 1 or more digits followed by 1 or more letters or 1 or more letters followed by 1 or more digits. Once that is out of the way, the rest of the string must be all alphanumerics.  The ^ and $ make sure the whole string is included in the match.
    (I have not tested this at all, just typed it up hopefully I got all the brackets in the right place).
    I think you just made my point.  TWICE.  While the lex class would be much more readable as a ring.... I know all my brackets are in the correct places and don't need to hope.
    Jeff

  • 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. ;-)

  • 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/ .

  • 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.

  • I want to know string contain symbol

    hhi
    i wana to know that if string contain symbol then remove the
    symbol from string
    i dont know which type of symbol is in string find and remove
    the symbol and put spacce
    like this
    string is ================"screen-capturing"
    result will be screen capturing
    tell me the result

    It would take a lot longer time that I have to explain how
    regular
    expressions work. And I only know the bare basics of them to
    begin
    with. Basically a regular expression is a pattern matching
    algorithm.
    You say what letters you want to find and what you want to do
    with those
    characters.
    function cleanString(vText){
    return vText.replace(/[^0-9a-z]|"_"/gi," ");
    In this example, the javascript replace function looks for
    the stuff in
    the beginning between the / marks and replaces it with the "
    " (space).
    The ^ character means "not" and everything in the brackets is
    what we
    are not looking for. i.e. it is saying that anything that is
    not a
    number (0-9) or a letter (a-z). Then the | pipe character
    means "or".
    So in addition to the non alphanumerics, it is also looking
    for "_" the
    underscore. Then after the last / are the switches. The g
    switch says
    to match all of the instances of the pattern (without the g,
    it would
    only replace the 1st one) and the i tells it to be
    case-insensitive..
    Now are you more confused than before?
    Here is a pretty good site with some more specific
    information about how
    the replace method works in Javascript:
    http://www.regular-expressions.info/javascript.html
    If you really want to get deep into regex, find the xtra for
    Director
    called pRegEx. It is free and super powerful and superfast.
    The
    documentation that comes with it is extremely detailed about
    all the
    different functions of regular expressions and how to use
    them in Director.

  • How to find out the containing jinternalframe?

    anyone know the solution to this problem?:
    1. i have a jinternalframe
    2. in the jinternalframe i have a jlist
    3. each list cell is rendered with a jlabel
    4. i have an action emanating from one of the list cells
    5. in the action handler, i need to get a reference to the containing internalframe
    of the component that is the source of the event (the jlabel rendered inside
    the jlist).
    in java 5, oddly, SwingUtilities.getAncestorOfClass() (that is, walking up the
    component hierarchy) works.
    in java 6, it doesn't.
    the problem is that jlists and other such model components are leaf components.
    they represent a discontinuity in the component containment hierarchy. the poor
    list cell renderers are and must remain dumb.
    anyhow, back to my question: is there any way to find out the containing
    jinternal frame?
    thanks, eitan

    is there any way to find out the containing jinternal frame?Not sure about the Renderer part, but here's a simple demo that puts a JList in a JScrollPane, which is then put on a JPanel, which is then put on the contentPane of a JFrame. Once the frame has been realized (this is key), there's a recursive method that will find whatever you're looking for.import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class MyFrame extends JFrame
      Component mysteryParent;
      public MyFrame()
        super("Find Parent");
        setName("The Amazing Frame");
        setDefaultCloseOperation(EXIT_ON_CLOSE);
        JList list = new JList();
        JScrollPane scroll = new JScrollPane(list);
        scroll.setName("The Silly Scroll");
        JPanel panel = new JPanel(new BorderLayout());
        panel.setName("The Plain Panel");
        panel.add(scroll, BorderLayout.CENTER);
        Container c = getContentPane();
        c.setLayout(new BorderLayout());
        c.add(panel, BorderLayout.CENTER);
        pack();
        // first, let's try to find the containing frame
        mysteryParent = getParentOf(list, JFrame.class);
        if (mysteryParent != null)
          System.out.println("The frame that contains the list is: " + mysteryParent.getName());
        // then, let's try to find the containing panel
        mysteryParent = getParentOf(list, JPanel.class);
        if (mysteryParent != null)
          System.out.println("The panel that contains the list is: " + mysteryParent.getName());
        // finally, let's try to find the containing scroll pane
        mysteryParent = getParentOf(list, JScrollPane.class);
        if (mysteryParent != null)
          System.out.println("The scrollPane that contains the list is: " + mysteryParent.getName());
      // recursive method:
      public Component getParentOf(Component child, Class parentClass)
        Component parent = null;
        if (child != null)
          parent = child.getParent();
        if (parent == null)
          return null;
        else if (parentClass.isInstance(parent))
          return parent;
        return getParentOf(parent, parentClass);
      public static void main( String[] args )
        MyFrame frame = new MyFrame();
        frame.setVisible(true);
    }I just swagged this just now, so maybe it could be improved.
    I'm guessing that SwingUtilities.getAncestorOfClass() already does this, but I've never used it so I'm not sure.

  • PowerShell script to find a string of characters in office documents in Doc Libraries and List Item attachments?

    Hi there,
    For SharePoint 2010 site - Does someone have the PowerShell script to find a string of characters in Office/Word/Excel/PDF documents in document libraries or the ones attached to List Items?
    Thanks so much in advance.

    Hi,
    According to your description, my understanding is that you want to find some specific string character in list items using PowerShell Command.
    $w = Get-SPWeb "http://devmy131"
    $l = $w.GetList("http://devmy131/lists/fieldslist");
    $i = $l.Items[0]["Title"].ToString();
    if ($i -like '*document*')
    Write-Host "Title contains document character" $i;
    More information:
    PowerShell -contains -like
    Thanks
    Best Regards
    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact
    [email protected]

  • [AS] Find a string of words in text

    Hello - hopefully someone can help as I'm now stuck on this. I want to be able to find a specific string of words within a text frame, though I want to be able to do this without using the Find Text Preferences approach.
    I can get it to work if i am just finding one word, but if there is more than one word it doesn't work.
    For example this works (given a text frame with text in that contains the word Example):
    tell application "Adobe Indesign CS5"
    tell active document
    set mybox to selected
      tell mybox
       set myfind to object reference of every word whose contents = "Example"
      end tell
    end tell
    end tell
    However the same does not work (searching for "The Example", which is two words)
    tell application "Adobe Indesign CS5"
    tell active document
    set mybox to selected
      tell mybox
       set myfind to object reference of every word whose contents = "The Example"
      end tell
    end tell
    end tell
    What i can't figure out is the correct phrasing for finding a string of words, i guess i should not be looking for the object reference of WORD, but nothing else i've tried seems to work. Many thanks for any help

    I think what John has said is correct… I only had a quick look in the dictionary terms. Without find/change the closest you may get is line or paragraph after that you would need to manipulate the line/para contents further… Word by definition I would think can't contain space but is encapsulated in space bar first/last…
    tell application "Adobe InDesign CS5"
    tell active document
    tell story 1
    set myfind to object reference of every word whose contents = "Example"
    end tell
    show text first item of myfind
    end tell
    end tell
    This would show the line you can then break down further…
    tell application "Adobe InDesign CS5"
    tell active document
    tell story 1
    set myfind to object reference of every line whose contents contains "For Example"
    end tell
    show text first item of myfind
    end tell
    end tell

  • Execute a string containing a PL/SQL block

    Hi,
    I would like to build a string containing a PL/SQL block and execute it dynamically. Is there way to do this.
    Note - The reason I want to this is because, based on certain table data dictionary views the declaration section of the PL/SQL block that I am building might vary
    I tried to use EXECUTE IMMEDIATE, it didn't work, pls let me know if I am missing something.
    DECLARE
    v_str VARCHAR2(1000);
    BEGIN
    v_str := 'BEGIN NULL; END';
    EXECUTE IMMEDIATE v_str;
    END;
    /

    Hi,
    Just happened to find it. EXECUTE IMMEDIATE can be used, the bug with my code was I didn't have a ; after the END statement. Corrected code is below, thanks for your time
    DECLARE
    v_str VARCHAR2(1000);
    BEGIN
    v_str := 'BEGIN NULL; END;';
    EXECUTE IMMEDIATE v_str;
    END;
    /

  • Encode/Decode a String containing Chinese etc. characters to/from unicode

    Hi, I am working to encode a multilingual String (English, chinese, japanese, Latin etc) as unicode. The encoded string is used as follows
    1)decoded by the User Interface for display purpose. The user interface is a web UI and
    2)read by user. So it should be human readable when it contains only English and special characters.
    Thus having a string that contains letters from English, Japanese, CHinese etc, we want the Japanese/Chinese characters to be encoded by the hex values such as &#31169; be encoded as %E7%A7%81.
    However, it is preferable that other special characters like ! ? , space etc not be encoded and left as such.
    The encoding of characters is achievable by using Java.net.URLEncoder but it also replaces all special characters including space character, which becomes a pain for the reader.
    Unfortunately URLEncoder.java does not have any API to configure which characters to encode. Any suggestions how I can proceed, or what encoder i can use?
    Thanks in advance!
    Regards

    I have to say that I disagree that "%E7%A7%81" is "human-readable". On the contrary, I would say that "&#31169;" is human-readable; even though I don't understand it myself, there are a lot of humans who do.
    But let's say that "human-readable" wasn't the right term. Maybe you just wanted a representation of an arbitrary Unicode string in ASCII characters only. In which case I would recommend Base-64 encoding. It does make everything unreadable, though, whereas your requirements appear to be to only make languages other than English be unreadable. So if you don't like that you are going to have to write your own encoder.
    Note also that your original premise:
    Hi, I am working to encode a multilingual String (English, chinese, japanese, Latin etc) as unicode.is misguided, since all data in Java Strings is already Unicode characters.

  • Error: Find criteria must contain at least one sort field value.

    Hi
    I am getting the followng error in Sort.as when I click on a column in a DataGrid that is bound to a nested property (e.g. parent.name)
    Error: Find criteria must contain at least one sort field value.
    I can see why this is failing.
    In the findItem function of Sort.as the code tests whether there is data in line (456) hasFieldName = values[fieldName] !== undefined. This fails and so an error is raised later in the function by:
         if (fieldsForCompare.length == 0)     {
         message = resourceManager.getString("collections", "findRestriction"); 
              throw new SortError(message);     }
     The code needs to traverse down the object hierarchy to get the field so that error is not thrown .
    The code needs to traverse down the object hierarchy to get the field so that error is not thrown .
    In the case of a non nested property, everything works fine.
    There is lots of discussion about nested properties in DataGrid and there is this jira:
    http://bugs.adobe.com/jira/browse/SDK-9801
    There is talk of using a labelFunction or an itemRenderer and other third party solutions (extensions of DataGridColumn).
    Is this a bug?  is there a workaround using labelFunction or itemRenderer which can stop the error in Sort.as?
    James
    Here is the code of findItem in Sort.as of SDK 3..4.0.9271
    public  
    function findItem(items:Array,values:Object,
    mode:String,
    returnInsertionIndex:Boolean =
    false,compareFunction:Function =
    null):int{
    var compareForFind:Function; 
    var fieldsForCompare:Array; 
    var message:String; 
    if (!items){
    message = resourceManager.getString(
    "collections", "noItems"); 
    throw new SortError(message);}
    else if (items.length == 0){
    return returnInsertionIndex ? 1 : -1;}
    if (compareFunction == null){
    compareForFind =
    this.compareFunction; 
    // configure the search criteria
    if (values && fieldList.length > 0){
    fieldsForCompare = [];
    //build up the fields we can compare, if we skip a field in the
    //middle throw an error. it is ok to not have all the fields
    //though
    var fieldName:String; 
    var hadPreviousFieldName:Boolean = true; 
    for (var i:int = 0; i < fieldList.length; i++){
    fieldName = fieldList[i];
    if (fieldName){
    var hasFieldName:Boolean; 
    try
    hasFieldName = values[fieldName] !==
    undefined;}
    catch(e:Error){
    hasFieldName =
    false;}
    if (hasFieldName){
    if (!hadPreviousFieldName){
    message = resourceManager.getString(
    "collections", "findCondition", [ fieldName ]); 
    throw new SortError(message);}
    else
    fieldsForCompare.push(fieldName);
    else
    hadPreviousFieldName =
    false;}
    else
    //this is ok because sometimes a sortfield might
    //have a custom comparator
    fieldsForCompare.push(
    null);}
    if (fieldsForCompare.length == 0){
    message = resourceManager.getString(
    "collections", "findRestriction"); 
    throw new SortError(message);}
    else
    try
    initSortFields(items[0]);
    catch(initSortError:SortError){
    //oh well, use the default comparators...
    else
    compareForFind = compareFunction;

    I have tried a sortCompareFunction:
    var sort:Sort = new Sort();
    sort.compareFunction = compareFunction;sort.fields = [sortField];
    data.sort = sort;
    data.refresh();
    this makes no difference.
    James

  • Using Regex to find a string

    Is it viable to use regular expressions with Search "Specific Tag" (i.e.script) "With Attribute" (i.e. src) and "=" a regex string rather than an exact search term?  The Find / Replace tool seems to prevent a simple wildcard find (i.e. "searchter* for searchterm) Any insight would be appreciated.

    uneAaron wrote:
    I'm trying to replace a script source value for all instances where the value contains the string "/bbcswebdav/xid-144702_1", where the string "xid-" is followed by a different numerical value in each instance.
    The regex for finding that string is:
    \/bbcswebdav\/xid\-[\d_]+
    The numerical value contains an underscore, so the final section ( [\d_]+ ) uses a range that selects one or more numbers and/or underscores.
    Perhaps as important as identifying what you want to find is specifying how you want to replace it. Regexes can have capturing groups that can be used in the Replace field to simplify matters.

  • @FINDSTR - How to find an element containing . (dot) when . (dot) is wildcharacter

    I'm checking a LogFile containing FileName(s) and want to Include/Exclude files according to FileType.
    How to use @FINDSTR  to find an element containing . (dot) when . (dot) is wildcharacter...???

    PowerShell ${"%MainDir%\%FullPath%\%FullFileName%"} = Get-Content ${"%MainDir%\%FullPath%\%ListFileName%"}
    |Select-String '\.mp3|\.mp4|\.m4a|\.flac|\.cue|\.ogg|\.ape|\.wav|\.wv'
    That wont work. Two things wrong
    First thing
    Get-Content expects a filename  like Get-Content c:\music.txt  
    or  Get-Content
    "%MainDir%\%FullPath%\%ListFileName%"  
    Get-Content ${c:\music.txt} will try to get the filename in the file c:\music.txt and not use c:\music.txt
    itself.
    Second Thing
    ${"%MainDir%\%FullPath%\%FullFileName%"} = is wrong, don't use the " inside the { }, the { } act as a
    quotes
    for example ${C:\My Documents\Music.txt} = is ok, that will work, this is a variable
    PowerShell ${"%MainDir%\%FullPath%\%FullFileName%"} = Get-Content ${"%MainDir%\%FullPath%\%ListFileName%"}
    |Select-String '\.mp3|\.mp4|\.m4a|\.flac|\.cue|\.ogg|\.ape|\.wav|\.wv'
    Should be 
    PowerShell ${%MainDir%\%FullPath%\%FullFileName%} = Get-Content "%MainDir%\%FullPath%\%ListFileName%"
    |Select-String '\.mp3|\.mp4|\.m4a|\.flac|\.cue|\.ogg|\.ape|\.wav|\.wv'

Maybe you are looking for