How to search char in a string

hi, i am new to JSP.
i have a string, for example an address "Frauenstrasse 10", i want to split it into street name "Frauenstrasse" and house number "10". but i don't know the syntax to process String. can anyone help? thanks!

new StringTokenizer(myString," "); // Tokens just space
or
new StringTokenizer(myString); // Tokens white space
token.hasMoreTokens(); - boolean
token.nextToken(); - Returns String
Stick in While loop.

Similar Messages

  • How to search for a pattern string in entire registry and delete all the keys and subkeys that contain the pattern (C# or VB)?

    I want to search for a pattern string in the entire registry and need to delete all the keys and sub-keys that contain the pattern. How can I implement this in VB Script or C#? Appreciate if you can give some sample examples. Now every time, I am manually
    searching for the pattern in registry and deleting one by one.
    Thanks Prasad

    There is no built in way to do this. You'll end up having to enumerate all keys and values in the entire registry and comparing each one for a pattern using Regex or similar.  This is going to be really slow but there isn't much else you can do about
    it (other than parallelize the enumeration).  Also note that you won't have permissions to all keys for read and/or write access so you'll need to skip over those using exception handling.
    Michael Taylor
    http://blogs.msmvps.com/p3net

  • How to search for subset of string

    Hi,
    I'm trying to implement Oracle text in 8i and 9i to search for a given string or a subset of string.
    For example, if the given string="Database Technology", I would like intermedia to first search for the exact string - "Database Technology",
    if not found, then search for either "Database" or "Technology".
    I'm only able to search for the exact string ("Database Technology") so far by using the contain clause. I'm not able to get Oracle Text to return me any records that also contains "Database" or "Technology" if the exact match "Database Technology" cannot be located.
    Any help is very much appreciated.
    thanks.
    elain

    You need to use the ACCUM operator. It raises the score based on the the frequencies of more than one word. Here are the contents of my TEXT1 test table:
    TEXT
    database
    server
    database server
    database blah blah database
    database blah blah server
    select score(1), text1.* from text1 where contains(text,'database ACCUM server ACCUM database server',1) > 0 order by score(1) desc;
    and here are the results:
    SCORE(1) TEXT
    68 database server
    34 database blah blah server
    2 database blah blah database
    1 server
    1 database
    You may want to put a multiplier on the "database server" phrase's score to increase the score on when the complete phrase is found. That looks like this, for example:
    select score(1), text1.text from text1 where contains(text,'database ACCUM server ACCUM database server*3',1) > 0 order by score(1) desc
    Tom Best

  • How to search and replace a string in Excel Shape (textbox) using Powershell.

    I have been asked to write a PS script to search/replace a string when found in Excel Shapes when they are textboxes. I have seen lots of simplistic PS scripts and even I can do a "foreach" loop through all the Shapes on a Sheet and display the
    Name of each Shape. But I have not found a property or method to expose the actual text in a textbox let alone change it.
    I have seen vba script that does this as:  
    Set xWs = Application.ActiveWorkbook.Worksheets(I)
    For Each shp In xWs.Shapes
    xValue = shp.TextFrame.Characters.Text
    shp.TextFrame.Characters.Text = VBA.Replace(xValue, xFindStr, xReplace, 1)
    Next
    In Powershell, shp.TextFrame.Characters.Text is ignored and returns nothing.  It would be nice to know if this is possible in PS and if so, know how to do it and/or get an example to work from.  I would have thought that
    PS and VB would use the same Excel object model but apparently they do not.
    I am using Excel 14.0 and PS 3.
    Any suggestions would be appreciated,
    Michael

    This didn't work for me.  I have the shape object and it shows the textframe property:
    PS C:\> $shape | gm
       TypeName: System.__ComObject#{00024439-0000-0000-c000-000000000046}
    Name                       MemberType Definition
    Apply                      Method     void Apply ()
    CanvasCropBottom           Method     void CanvasCropBottom (float)
    SoftEdge                   Property   SoftEdgeFormat SoftEdge () {get}
    TextEffect                 Property   TextEffectFormat TextEffect () {get}
    TextFrame                  Property   TextFrame TextFrame () {get}
    TextFrame2                 Property   TextFrame2 TextFrame2 () {get}
    ThreeD                     Property   ThreeDFormat ThreeD () {get}
    But trying to access it gives an error:
    PS C:\> $shape.textframe | gm
    gm : You must specify an object for the Get-Member cmdlet.
    At line:1 char:20
    + $shape.textframe | gm
    +                    ~~
        + CategoryInfo          : CloseError: (:) [Get-Member], InvalidOperationException
        + FullyQualifiedErrorId : NoObjectInGetMember,Microsoft.PowerShell.Commands.GetMemberCommand
    PS C:\> $shape.TextFrame.Characters().text="hello"
    You cannot call a method on a null-valued expression.
    At line:1 char:1
    + $shape.TextFrame.Characters().text="hello"
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
        + FullyQualifiedErrorId : InvokeMethodOnNull
    I hope this post has helped!

  • How to search for a specific String within an ArrayList

    I am creating an inherited class, CD, that has a field of "tracks". I am wondering how you would search through the ArrayList and list the track number that correlates with a search term. For instance, if I have a track called "Radar Love" and it is track number 2, how would I create the search function to find out what track number "Radar Love" is?

    trojansc82 wrote:
    int index = 0;
    boolean found = false;
    while(index < tracks.size() && !found){
    String track = tracks.get(index);
    if(track.contains(searchString)){
    found =true;
    else{
    index++;
    return index;It's still the same code. I attempted putting in a return statement with tracks.get(index), but it didn't work.Edited by: Edward_Kimber on Nov 15, 2008 2:57 PM

  • How to search for a text string in Reports designer?

    In iDS reports (10gR2), I want to search from top down for a text string was used in one of the queries or triggers. In Forms, you can do it, in reports the related menu item is always seems to be grayed out no matter what item I pick in the Navigator. Is it doable or not? If yes, then how. I don't wanna open each program piece including the queries in the data model, report triggers or program units and look for (by visual scanning) for the text I am searching for. This is crazy. There must be a way to do it. Thanx.

    That is pretty bad for such an expensive report development program. The forms allows it, I wonder why Oracle did not include similar functionality in the reports developer. I knew the conversion to ascii, but during development it is pain in the ... just to search for a simple text string in the related program units in the report, to convert to ascii, do the search and then go back to the developer. Anyway, if that is the only way, there is nothing we can do I guess :(

  • How to search a word in string

    hi all
    tstxt = 'mnr ptds xyz king fox'.
    i want to make a condition..like
    if tstxt contains king.  *
    execute statement.
    endif.
    how can i search the word in string

    Hi,
    You can search like this
    if tstxt CS 'king'. "CS stands for Contains String a relational operator.
    *Execute here
    endif.
    Regards,
    Sesh

  • How to add chars to a String

    Hi,
    I want to construct a string by adding characters to it.
    How can I do this ?

    Never mind, yes it will work (except that you have to
    initialize the string first, like s = "something";)
    before using +=. Sorry.actually, you don't. s += "foo" is really shorthand for s = s + "foo".
    since the reference s is equal to null, the value null is converted to the String "null".
    therefore, String s = null;
    s += "foo";has the same effect as
    String s = "null" + "foo";so, strictly speaking, you don't have to initialize s to a non-null value, but if you don't, you're not going to get anything you'd like...
    and, StringBuffer is definitely the way to go here; otherwise, each time you concatenate a character to your String, you're creating a new Character object and a new String object.
    Larry

  • How to convert char array to string

    sirs,
    i have written a method in java which will return a randomly generated string of a fixed length. i am creating one one character and inserting it into char array.
    at last i am converting it to string
    like this
    String newpass= pass.toString();// pass is a char array
    but problem is that the string is having different value what i hav generated.
    if i am doing like this..
    String newpass= new String(pass);// pass is a char array
    here newpass is having correct value but having some error
    error in the sense when i print
    System.out.println(newpass+"some text");
    "some text" is not printing
    can you suggest the better way

    /*this is my method */
    private String generateString(int len){
              char pass[] = new char[10];
              int cnt=0;
              int temp=0;
              Random randomGenerator = new Random();
                   for (int idx = 0; idx < 1000; ++idx)
                        temp = randomGenerator.nextInt(1000)%128;
                   if((temp>=65 && temp<=90)||(temp>=97 && temp<=122)||(temp>=48 && temp<=57))
                             pass[cnt]=(char)temp;
                             cnt++;               
                        if(cnt>=len) break;
                   String newpass= pass.toString();
                   String newpass1= new String(pass);
                   System.out.println("passed pass"+newpass+"as"+newpass1+"sa");
              return newpass;
    here newpass and newpass1 are having separate values
    why ??
    Edited by: Shovan on Jun 4, 2008 2:21 AM

  • How to search for a matching string

    <cfcatch>
    <CFMAIL to="[email protected]" From="[email protected]"
    Subject="Error message" Type="HTML">
    #cfcatch.message#
    </CFMAIL>
    </cfcatch>
    I need to create a condition based on the string in the
    message, if #cfcatch.message# is "The element at position 12 of
    dimension 3 can not be found" I need to deliver certain message
    through email BUT if #cfcatch.message# is matching other
    sentence I need to deliver a different message.
    I used the following condition (see below) but it somehow did
    not work, even when I know for sure the error message is saying the
    right think, for example, "The element at position 12...etc"
    Is there a way to do this differently or have I done it wrong
    somewhere?
    <cfif #cfcatch.message# EQ "The element at position 12 of
    dimension 3 can not be found">
    Deliver message 1
    cfelse>
    Deliver message 2
    </cfif>

    Why not catch a specific error type?
    <cftry>
    <cfthrow type="foo.bar.custom" message="anything you want
    to say!">
    <cfcatch type="foo.bar.custom">
    Do something special here!
    </cfcatch>
    <cfcatch type="Any">
    An Unknown error has occured!
    </cfcatch>
    </cftry>
    If you're not sure of the error that is being thrown, dump
    the cfcatch and grab the first part of the stack trace and then
    recode using that error type in your cfcatch block.
    Here's an example of catching an invalid file format upload
    with cffile.
    <cftry>
    <cffile action="upload" destination="#pathInfo#"
    fileField="imagefile" nameconflict="makeunique" accept="image/jpg,
    image/jpeg, image/png, image/eps, image/tif, image/gif,
    application/pdf" >
    <cfcatch
    type="coldfusion.tagext.io.FileTag$InvalidUploadTypeException">
    Invalid File Type
    </cfcatch>
    </cftry>

  • How to Search  '&'  char

    Hi,
    i tried to find all customers with &CO in the customer name.
    Result--> No data found
    my code is
    AND nvl(upper("CUSTOMER_NAME"),'%') like '%'||upper(:P1001_CUST_NAME)||'%'
    Any help
    Thanks in advance
    Costantino

    Costantino
    take a look at
    Re: wild card searching in sql squery (pl/sql function body returning......
    hope this helps.
    Leo

  • How to delete the last char in a String?

    i want to delete the last char in a String, but i don't want to convert the String to a StringBuffer or an array, who knows how to do?

    Try it in this way
    String MyString = "ABCDEF";
    MyString = MyString.substring(0,MyString.length()-1);

  • How to search a special string in txt file and return it's position in txt file?

    How to search a special string in txt file and return it's position in txt file?

    I just posted a solution for a similar question here:  http://forums.ni.com/ni/board/message?board.id=170​&view=by_date_ascending&message.id=362699#M362699
    The top portion can search for the location of a string, while the bottom portion is to locate the position of a character.  Both can search for a character.
    The position of the character within the file is displayed in the indicator(s).
    R

  • How to search for particular string in array?

    I am struggling to figure out how to search array contents for a string and then delete the entry from the array if it is found.
    The code for a program that allows the user to enter up to 20 inventory items (tools) is posted below; I apologize in advance for it as I am also not having much success grasping the concept of OOP and I am certain it is does not conform although it all compiles.
    Anyway, if you can provide some assistance as to how to go about searching the array I would be most grateful. Many thanks in advance..
    // ==========================================================
    // Tool class
    // Reads user input from keyboard and writes to text file a list of entered
    // inventory items (tools)
    // ==========================================================
    import java.io.*;
    import java.text.DecimalFormat;
    public class Tool
    private String name;
    private double totalCost;
    int units;
      // int record;
       double price;
    // Constructor for Tool
    public Tool(String toolName, int unitQty, double costPrice)
          name  = toolName;
          units = unitQty;
          price = costPrice;
       public static void main( String args[] ) throws Exception
          String file = "test.txt";
          String input;
          String item;
          String addItem;
          int choice = 0;
          int recordNum = 1;
          int qty;
          double price;
          boolean valid;
          String toolName = "";
          String itemQty = "";
          String itemCost = "";
          DecimalFormat fmt = new DecimalFormat("##0.00");
          // Display menu options
          System.out.println();
          System.out.println(" 1. ENTER item(s) into inventory");
          System.out.println(" 2. DELETE item(s) from inventory");
          System.out.println(" 3. DISPLAY item(s) in inventory");
          System.out.println();
          System.out.println(" 9. QUIT program");
          System.out.println();
          System.out.println("==================================================");
          System.out.println();
          // Declare and initialize keyboard input stream
          BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
          do
             valid = false;
             try
                System.out.print(" Enter an option > ");
                input = stdin.readLine();
                choice = Integer.parseInt(input);
                System.out.println();
                valid = true;
             catch(NumberFormatException exception)
                System.out.println();
                System.out.println(" Only numbers accepted. Try again.");
          while (!valid);
          while (choice != 1 && choice != 2 && choice != 9)
                System.out.println(" Not a valid option. Try again.");
                System.out.print(" Enter an option > ");
                input = stdin.readLine();
                choice = Integer.parseInt(input);
                System.out.println();
          if (choice == 1)
             // Declare and initialize input file
             FileWriter fileName = new FileWriter(file);
             BufferedWriter bufferedWriter = new BufferedWriter(fileName);
             PrintWriter dataFile = new PrintWriter(bufferedWriter);
             do
                addItem="Y";
                   System.out.print(" Enter item #" + recordNum + " name > ");
                   toolName = stdin.readLine();
                   if (toolName.length() > 15)
                      toolName = toolName.substring(0,15); // Convert to uppercase
                   toolName = toolName.toUpperCase();
                   dataFile.print (toolName + "\t");
                   do
                      valid = false;
                      try
                         // Prompt for item quantity
                         System.out.print(" Enter item #" + recordNum + " quantity > ");
                         itemQty = stdin.readLine();
                         // Parse integer as string
                         qty = Integer.parseInt (itemQty);
                         // Write item quantity to data file
                         dataFile.print(itemQty + "\t");
                         valid=true;
                      catch(NumberFormatException exception)
                         // Throw error for all non-integer input
                         System.out.println();
                         System.out.println(" Only whole numbers please. Try again.");
                   while (!valid);
                   do
                      valid = false;
                      try
                         // Prompt for item cost
                         System.out.print(" Enter item #" + recordNum + " cost (A$) > ");
                         itemCost = stdin.readLine();
                         // Parse float as string
                         price = Double.parseDouble(itemCost);
                         // Write item cost to data file
                         dataFile.println(fmt.format(price));
                         valid = true;
                      catch(NumberFormatException exception)
                         // Throw error for all non-number input (integers
                      // allowed)
                         System.out.println();
                         System.out.println(" Only numbers please. Try again.");
                   while (!valid);
                   // Prompt to add another item
                   System.out.println();
                   System.out.print(" Add another item? Y/N > ");
                   addItem = stdin.readLine();
                   while ((!addItem.equalsIgnoreCase("Y")) && (!addItem.equalsIgnoreCase("N")))
                      // Prompt for valid input if not Y or N
                      System.out.println();
                      System.out.println(" Not a valid option. Try again.");
                      System.out.print(" Add another item? Y/N > ");
                      addItem = stdin.readLine();
                      System.out.println();
                   // Increment record number by 1
                   recordNum++;
                   if (addItem.equalsIgnoreCase("N"))
                      System.out.println();
                      System.out.println(" The output file \"" + file + "\" has been saved.");
                      System.out.println();
                      System.out.println(" Quitting program.");
            while (addItem.equalsIgnoreCase("Y"));
    // Close input file
    dataFile.close();
       if (choice == 2)
       try {
          Read user input (array search string)
          Search array
          If match found, remove entry from array
          Confirm "deletion" and display new array contents
       catch block {
    } // class
    // ==========================================================
    // ListToolDetails class
    // Reads a text file into an array and displays contents as an inventory list
    // ==========================================================
    import java.io.*;
    import java.util.StringTokenizer;
    import java.text.DecimalFormat;
    public class ListToolDetails {
       // Declare variable
       private Tool[] toolArray; // Reference to an array of objects of type Tool
       private int toolCount;
       public static void main(String args[]) throws Exception {
          String line, name, file = "test.txt";
          int units, count = 0, record = 1;
          double price, total = 0;
          DecimalFormat fmt = new DecimalFormat("##0.00");
          final int MAX = 20;
          Tool[] items = new Tool[MAX];
          System.out.println("Inventory List");
          System.out.println();
          System.out.println("REC.#" + "\t" + "ITEM" + "\t" + "QTY" + "\t"
                + "PRICE" + "\t" + "TOTAL");
          System.out.println("\t" + "\t" + "\t" + "\t" + "PRICE");
          System.out.println();
          try {
             // Read a tab-delimited text file of inventory items
             FileReader fr = new FileReader(file);
             BufferedReader inFile = new BufferedReader(fr);
             StringTokenizer tokenizer;
             while ((line = inFile.readLine()) != null) {
                tokenizer = new StringTokenizer(line, "\t");
                name = tokenizer.nextToken();
                try {
                   units = Integer.parseInt(tokenizer.nextToken());
                   price = Double.parseDouble(tokenizer.nextToken());
                   items[count++] = new Tool(name, units, price);
                   total = units * price;
                } catch (NumberFormatException exception) {
                   System.out.println("Error in input. Line ignored:");
                   System.out.println(line);
                System.out.print(" " + count + "\t");
                System.out.print(line + "\t");
                System.out.print(fmt.format(total));
                System.out.println();
             inFile.close();
          } catch (FileNotFoundException exception) {
             System.out.println("The file " + file + " was not found.");
          } catch (IOException exception) {
             System.out.println(exception);
          System.out.println();
       //  Unfinished functionality for displaying "error" message if user tries to
       //  add more than 20 tools to inventory
       public void addTool(Tool maxtools) {
          if (toolCount < toolArray.length) {
             toolArray[toolCount] = maxtools;
             toolCount += 1;
          } else {
             System.out.print("Inventory is full. Cannot add new tools.");
       // This should search inventory by string and remove/overwrite matching
       // entry with null
       public Tool getTool(int index) {
          if (index < toolCount) {
             return toolArray[index];
          } else {
             System.out
                   .println("That tool does not exist at this index location.");
             return null;
    }  // classData file contents:
    TOOL 1     1     1.21
    TOOL 2     8     3.85
    TOOL 3     35     6.92

    Ok, so you have an array of Strings. And if the string you are searching for is in the array, you need to remove it from the array.
    Is that right?
    Can you use an ArrayList<String> instead of a String[ ]?
    To find it, you would just do:
    for (String item : myArray){
       if (item.equals(searchString){
          // remove the element. Not trivial for arrays, very easy for ArrayList
    }Heck, with an arraylist you might be able to do the following:
    arrayList.remove(arrayList.indexOf(searchString));[edit]
    the above assumes you are using 1.5
    uses generics and for each loop
    [edit2]
    and kinda won't work it you have to use an array since you will need the array index to be able to remove it. See the previous post for that, then set the value in that array index to null.
    Message was edited by:
    BaltimoreJohn

  • How to search for a particular word in a string?

    How to search for a particular word in a string?
    thanks for your help....

    This works fine.
    public class Foo {
        public static void main(String[] args) {
        String s = "Now is the time for all good...";
        String s2 = "the time";
        System.out.println(s.contains(s2));
        System.out.println(s.contains("for al"));
        System.out.println(s.contains("not here"));
    }output:true
    true
    falseYou must have something else wrong in your code.
    JJ

Maybe you are looking for

  • Help getting iphone 4s out of recovery mode as i keep getting error 1611 or error 21.

    can anyone help (with ways to fix this issue other than the 1's ive already tred) I was charging my phone and when i went to get off off charge it was dead and only displayed the itunes connect image. I have tried to restore it and when i connect it

  • Get data from PL/SQL block and generate the data file in UNIX

    Hi All i was executing the following code block from Unix Shell Script. The following code was generating the file count_curdate.txt with all require infomrations. The query gives number of records , group by partition_dt ABC=`sqlplus -s <<EOF > coun

  • Balance sheet evaluation

    Dear All, 1) May I know balance sheet evaluation monthly activity will be reversed whereas year end will not be reversed? The practice is just like F101 balance sheet evaluation on open item? 2) Also the balance sheet currency only in local currency

  • Hiding field in tableview iterator

    I have a table view iterator in which I am using 4 columns. But I want to hide one column in it. I want it to be generated since it's used in my calculations on the oninputprocessing but I don't want it to be displayed. Is this possible? Thanks. Code

  • Can anyone help? I'm losing my mind over this

    On 13th September, I called BT to advise them of a house move.  They took my new address, agreed a switch over date of 31st October and sent me an acknowledgement with an order number (BTCM0ZZ04*********). On the 24th October, they told me the previo