How to find a character in a word

Hello,
I have the following String s = "Mapple am a apple";
String s1 = "a";
int index = s.indexOf(s1);
Now i have to return a which is at the first place and if there are more letters after a . i.e i should return am a apple and not a in Mapple. HOw can i do this?
Thanks n advance.
sk

hi,
First put the string in Stringtokenizer.Select all words.then check what are the words that starts with "a".here is the program,
String [] res_str=new String[25];
int count=0;
StringTokenizer stk=new ("hello i am having an apple"," ");
while(stk.hasMoreElements())
String str="";
str=stk.nextElement();
if(str.startsWith("a"))
res_str[count++]=str;
return res_str;
try it ..its will work.
bye,
j.mouli

Similar Messages

  • How to find the ocuurence of a word from LIST A in LIST B in a text file?

    Hey if you look at the text file there is LIST A and LIST B.. i need to find the ocuurence of a word from LIST A in LIST B. Eg: if my output is (1,3)
    then first word from LIST A occurs in 3 places in LIST B.
    Can you please get the sample code to do this process.
    Please let me know..
    My text file looks like this below :
    phrases.txt
    LIST A
    aamsz
    abaffiliate
    aboard casino
    above computer
    above pop
    above violat
    LIST B
    http://209.153.231.131
    HTTP/1.0 200 OK
    Server: Microsoft-IIS/5.0
    Date: Mon, 02 Feb 2004 11:53:26 GMT
    IISExport: This web site was exported using IIS Export v2.2
    IISExport: This web site was exported using IIS Export v2.2
    Content-Length: 274
    Content-Type: text/html
    Set-Cookie: ASPSESSIONIDSSDBBBAR=OOGFKOJBMKMDCGPIHPADALHB; path=/
    aboard casino
    Cache-control: private
    abaffiliate
    above computer

    The key difference is that Vector is synchronized whilst ArrayList is not. Synchronized means that the classes methods can safely be accessed by different threads and as your application will not be multithreaded then the ArrayList is possibly the better option.
    To store Strings in an ArrayList, you first need to declare the ArrayList object something like this;
    ArrayList<String> listAList = new ArrayList<String>();and you would obviously do something similar for the ArrayList that will hold the Strings that should belong to List B.
    The first thing to note is that you can use the new (well new in version 1.5 anyway) generics techniques to specify the type of the object the ArrayList will hold; Strings in this case.
    To add a value into the ArrayList once you have read it from the file and decided if it belongs in the List A or List B ArrayList, all you need to do is call the add() method of the ArrayList something like this;
    // Assume that you read the line from the file into a variable called temp;
    listAList.add(temp);To compare the two lists, the easiest option would be to iterate through one ArrayList and ceheck to see if the values you recover from it are duplicated in the other ArrayList. Luckilly, ArrayList has another method that helps here, it is called contains();
    Assuming that you have two ArrayList(s), one called listAList that holds the Strings that belong to List A and another called listBList that holds the Strings that belong to ListB, you could do something like this to check for duplicates;
    for(String element : listAList) {
        if(listBList.contains(element)) {
            System.out.println("Found a match");
    }Hope that helps.

  • How to find Client Character set?

    Hi,
    I need to connect to remote database which is having different character set than the client. Ia there any method to display client character and Database character set from SQL Plus? Could someone please help me.
    Thanks in Advance
    Sree.

    I guess you're using PL/SQL Developer?
    (because I get that warning message too ;) )
    The warning also continues with:
    You can set the client character set thought the NLS_LANG environment variable or the NLS_LANG registry key.
    If I execute some scripts from client (client character set WE8MSWIN1252 and database character set UTF8) will
    it cause any problem?It depends on what kind of data you're loading/importing. (chinese characters for example)
    I never had any problems at all, since I'm not using 'exotic' characters.
    You can find related threads on http://asktom.oracle.com/pls/asktom/asktom.search?p_string=%22UTF8%22
    and more explanations in the Oracle Globalization Guide: http://download.oracle.com/docs/cd/B19306_01/server.102/b14225/toc.htm

  • How to find is character ?

    Hi All,
    I have a simple requirement and need some hint to resolve it.
    I need to find rows of a table where third place in the column value is occupied by a character - (like A, E etc.)
    SO that should return 23A1412,12D4124,32E3123 from below dataset.
    1220212
    23A1412
    2312312
    12D4124
    32E3123
    3123123
    23V23143
    Thanks
    Bhushan

    Hi try like this
    SQL> with t as(select '1220212' test_string from dual union all
      2  select '23A1412' from dual union all
      3  select '2312312' from dual union all
      4  select '12D4124' from dual union all
      5  select '32E3123' from dual union all
      6  select '3123123' from dual union all
      7  select '23V23143' from dual)
      8  select test_string from t
      9  where regexp_like(test_string,'[0-9A-Za-z][0-9A-Za-z][A-Za-z]');
    TEST_STR
    23A1412
    12D4124
    32E3123
    23V23143another test case
    SQL> with t as(select '1220212' test_string from dual union all
      2  select '23A1412' from dual union all
      3  select '2312312' from dual union all
      4  select '12D4124' from dual union all
      5  select '32E3123' from dual union all
      6  select '3123123' from dual union all
      7  select 'abc23123' from dual union all
      8  select 'a3e23143' from dual)
      9  select test_string from t
    10  where regexp_like(test_string,'[0-9A-Za-z][0-9A-Za-z][A-Za-z]');
    TEST_STR
    23A1412
    12D4124
    32E3123
    abc23123
    a3e23143Edited by: oracle_for_dude on Jul 29, 2009 2:46 PM

  • How to find the occurrence of a word

    Hi...how can i write a method to find the occurrence of a string......
    i was thinkin of using an arraylist...but is there another way of doing it without an arraylist?
    thanks

    Do you mean the occurence of a string in a DOM tree, an XML document, some other file on disk or in another String.
    For the latter, it is pretty easy...int startAt = 0;
    int count = 0;
    while (startAt  != -1 ) {
      if ( (startAt = myString.indexOf(searchString, startAt)) != -1 ) count++;
    }

  • How to find base character from an accented character

    Hi, given an accented character (�, �, �, etc...) is there a way to retrieve its base character? In the case above, a, o and c respectivelly?
    I searched in this forum and google and didn't find a definitive answer.
    The reason i need this is because in my database, some records have accented content, and now i need to generate a textfile to transfer daily to a bank, but the bank doesn't accept accented characters.
    Thanks.

    Decompose the Unicode string -- i.e., perform an NFC transformation -- and then strip off the diacritical marks, as done in VietPad editor.
    There is a native class, java.text.Normalizer, but it is not made public until Mustang release.
    http://java.sun.com/javase/6/jcp/beta/

  • How to Find ":\" special character in INI file using powershell

    Hi Guys,
    I'm googleing last two days for subjected powershell script but no luck.
    could you please help me to write a PS to find :\ in INI file!
    Thanks in advance
    Er Reddy

    Select-String file.ini -pattern '\:\\'
    ¯\_(ツ)_/¯
    or 
    Select-String file.ini -pattern ':\' -SimpleMatch
    [string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "

  • Find Database Character Set

    Friends,
    How to find "Database Character Set" of current database?

    Hi,
    SELECT * FROM DATABASE_PROPERTIES WHERE PROPERTY_NAME LIKE '%CHAR%SET%';Yoann.

  • How to find 11i and r12 applications characterset

    Hi,
    How to find 11i and r12 applications characterset not of database only applications,What is IANA characterset asked in rapid install?How to find IANA character set in 11i and r12
    Regards

    Hi,
    How to find 11i and r12 applications characterset not of database only applicationsAs applmgr user, source the application env file and issue "echo $NLS_LANG".
    You can also get it from the application context file (search for <NLS_LANG oa_var="s_nlslang">).
    What is IANA characterset asked in rapid install?How to find IANA character set in 11i and r12This is documented in the installation manual.
    The IANA (Internet Assigned Numbers Authority) character set is the Internet-assigned standard character set name used by the Web server. See http://www.iana.org/assignments/character-sets for more information.
    Regards,
    Hussein

  • How to find no of bytes per character in a word - Urgent need

    Hi,
    I have some data in the database with chinese characters. I want to know how many bytes per each character in a word and get the total bytes.
    Is there any built in Oracle function or anything where i can get no of bytes for each character or a word.
    I am not able to find the solution anywhere.
    Any help is appreciated.

    Hi,
    You can use LENGHTB function.
    SQL>SELECT LENGTHB(dummy) FROM DUAL;
    LENGTHB(DUMMY)
                 1
    1 row selected.
    SQL>Regards

  • How to find out how many space character in setence (string var) ?

    Dear all Master,
    I need Your help please.
    Topic:
    Script Editor.
    My System:
    -CUCM 7.0
    -UCCX 7.0 premium
    -Nuance recognizer 9.0
    Question:
    ABC = string var.
    ABC = "this is sample"
    2 space character in ABC string var.
    How to find out how many space character in ABC var ?
    Regards,
    Susanto

    Hi
    Create a int variable called whatever you want, then insert a SET step.
    Set the variable to the new int you created, and then paste this into the 'value' field:
    String[] myarray = teststring.split(" ");
    return myarray.length -1 ;
    Basically it splits the string into chunks each time it hits the " " character.
    This results in an array of the resulting chunks (i.e. words), which is one more than the number of spaces. -1 from that, and you have your int variable set to the number of spaces.
    Regards
    Aaron
    Please rate helpful posts...

  • How to find a specific word in sentence in each line?

    How to find a specific word in sentence in each line and output will show start from the beginning from specific word plus with small description from each sentence?
    For example: I need to find a "+Wednesday+" and "+Thursday+" word in each sentence by line by line from "myfile.txt".
    Go ballet class next Wednesday.
    On the Wednesday is going to swim class.
    We have a meeting on Thursday at Panda's.
    Then it will show the output:
    Wednesday : ballet class
    Wednesday : swim class
    Thursday: meeting at Panda's
    I am going to figure out in Java console to read from a file for specific word from each line and how to make it output in correct way. I know already to make input/file codes.

    I got it and understand much better. Thank you very much. There is a problem with it because I knew how to make
    a specific word in sentence but how I should make Output for specific word and some words from sentence.
    For example:
    Input:
    +"On Thursday go to ballet class"+
    +"Swim class on Friday one time a month at 2 p.m."+
    I used the codes for that:
    class FindSchedule{
         String firstline = "On Thursday go to ballet class ";
         String secondline = "Swim class on Friday one time a month ";
         FindSchedule(){
              System.out.println(firstline + findTheIndex("Thursday", firstline));
              System.out.println(secondline + findTheIndex("Friday", secondline));
         public int findTheIndex(String word, String sentence){
              int index;
              index = sentence.indexOf(word);
              return index;
         public static void main (String[] args){
              new FindSchedule();
    }The output will be:
    Thursday: ballet class
    Friday: 14:00 swim class one time a week
    Notice that time is changing in output complete different from input.
    I need to find out how to extract some words from each sentence for output. Do you know how to do it?

  • How to find a particular word in a file using java

    Program how to find a particular word in a file

    SirivaniG wrote:
    Program how to find a particular word in a fileOkay, I finished it. Now what?

  • How to find number of characters in a character string

    Hi,
      Can anyone please tell me about how to find the number of characters in a character string type variable.
    Reagards,
    Siva

    hi,
    Use STRLEN for Calculating String Length..
    Assign it to integer variable for Further Use.Suppse u need to find string length for "hai".. this piece of code will help u
    data:  var type string value 'hai',
             len type i.
    len = strlen(var).
    write len.

  • How to display a particular character  of a word

    Hi,
    can anyone tell me how to display  a particular character of a word in smart forms,Ex:suppose word is India and i want to display character d..
    Thanks in advance.
    Rajesh

    please look at the below explanation:
    DATA: VAR TYPE CHAR20.
    VAR = 'INDIA'.
    WRITE:/ VAR(3) - THIS WILL PRINT FIRST THREE CHARACTERS OF THE INDIA SO THE OUTPUT WILL BE : IND
    WRITE:/ VAR+3(1) = THIS WILL PRINT 1ST CHARACTER AFTER FIRST 3 CHARACTERS SO THE OUTPUT WILL BE : I
    COPY REQUIRED CHARACTERS IN ANOTHER VARIABLE.
    DATA: VAR2 TYPE CHAR10.
    VAR2 = VAR+3(2) .

Maybe you are looking for

  • Two external FW drives - Can't mount both at same time?

    Hi, I just got two new 200 GB ATA drives and I've installed them in two separate cases. I have managed to get both drives formatted and mounted, but only one at a time. If I have one drive switched on and mounted, as soon as I switch the other one on

  • HTML5 tag audio not working in Safari

    I've included a very simply HTML5 script in my webpage like this: <!DOCTYPE HTML> <html> <head> <title>HTML5 Player</title> </head> <body> <audio controls="controls" autoplay="autoplay" <div class="jive-quote"> <source src="http://www.mydomain.com/fo

  • HT4623 I keep getting kicked off my wi-fi connection. any ideas?

    I keep getting dumped from my wi-fi connection. I just made an ajustment to the security level and now I get dumped. My sons phone has no problem. I have been trying to get in to change the security level, but I keep getting error messages. I went in

  • Printing Photos through ePrint

    If you can email it, you can print it. That is the idea behind the ability to use ePrint.   Send pictures to your printer while you are out and living in the moment. Then go home to find mementos of your evening's activities already waiting on you.  

  • I have a Touchsmart 9100 PC with a built in webcam, but i cannot get the webcam to work, help?

    A light comes on the built in webcam when I for instance, activate a Skype video call, but no picture comes through.  I thought this might be a problem with Skype, so i instead tried to just use the webcam like a photobooth however the camera still w