Replace more then one occurance?

Hi i'm trying to replace all the characters in a line and keep an increment track of which one they are for example:
this is by blah I hope you enjoy my blah do you think they will like my blahturns into this
this is by 1turkey I hope you enjoy my 2turkey do you think they will like my 3turkeyI'm using regular expressions with a while loop and it's only doing the last occurance in the line, how can i get it so it's like the above example ?

class ReplacementTest
    public static void main(String[] args)
        new ReplacementTest().go();
    void go()
        String str = "this is by blah I hope you enjoy my blah do you think they will like my blah";
        System.out.println(numberedReplaceAll(str, "blah", "turkey"));
    String numberedReplaceAll(String str, String wordToReplace, String replacement)
        String[] tokens = str.split(wordToReplace);
        StringBuffer result = new StringBuffer();
        for (int i = 0; i < tokens.length; i++)
            result.append(tokens[i] + (i + 1) + replacement);
        return result.toString();
}

Similar Messages

  • Find and Replace more then one character

    Hi
    I need to find and replace more then one character. for example: I need to replace "A" with "a". "B" with "b" and so on. how to do that in one search?

    See the following script by Peter Kahrel:
    Change case
    http://www.kahrel.plus.com/indesign/grep_change_case.html
    If the "A" and the "B" are in arbitrary positions in your text you could use the following GREP:
    [AB]
    together with the script.
    For testing your GREP expressions, you could use the following script, also by Peter Kahrel:
    A GREP editor
    http://www.kahrel.plus.com/indesign/grep_editor.html
    Uwe

  • How can I restrict more then one user to access the table?

    Hi !
    I have a problem and two solutions and I am a bit confused as to
    which one is the best one and/or can there be any better way of
    handling the problem ?
    Problem : I have to update a key field of a table when I update
    it in the form 5.0 screen. I am basically doing a maintenance of
    a table and if a certain field is updated then the change has to
    be reflected in two more tables. But the issue is that the field
    is a part of the key in those two tables. So all I can think of
    is that I need to insert new set or rows for that new value of
    the field and delete the old set of records for old values of
    the field.
    There are two ways of doing it;
    1.One option can be to explicitely define two cursors separately
    and fetch the values in them one by one and then insert the new
    records and then delete the old records in both the tables. This
    I feel will be a cumbersome process both in terms of processing
    time and the coding.
    2.Second option I was thinking can be to create two flat tables
    (without keys) and insert the values in them and update the
    changed field there and then insert the rows in the respective
    tables. Delete the old records in the main tables and delets the
    records in these flat tables. This is a bit more faster and
    easier to predict and code. This seems to be a better option for
    me.
    Any comments on these ?
    In both the cases I was thinking of making some provision so
    that more then one person can't update the table simultaneously.
    Since if there are more then one persons doing the processing
    then some inconsistency might creep into the whole process.
    This is easier to do in the second process as if I check the
    data in the flat tables and if there is some data then I can
    presume that some one is doing the processing and I can ask the
    other person to hold for a while. But in this case how can I
    stop more then two people to simultaneously check for the empty
    table and start inserting the record ?
    I was just thinking of having a sepatare table having only one
    field and this will be a key field and as the process begins the
    process will insert a fix value say 'Y' in the key field and at
    the end of the process the record will be deleted and this way
    we can restrict the user to access the process more then one at
    a time..? Since you can't have same value of the key in a table
    more then once.
    Any better way of handling it will be deeply appreciated.
    How about locking the table at the begining and releasing the
    lock at the end ? Will there be any issue in that? since I am
    inserting and deleting the rows in the same transaction.
    Comments welcome,
    Shobhit
    null

    How about performing the update IN the database using a stored
    procedure?
    By using non-database fields on your form to get the
    information, you can then call the procedure in the database to
    perform the updates. If an error occurs in the procedure you
    rollback, if necessary, and send a message or status back to the
    form. If it succeeds you might wish to commit and then re-
    execute the form's query -- using either the original key values
    or the new key values...
    null

  • HT1296 How can i get my contacts to show on itunes on my laptop?  Or at least delete more then one at a time on my iphone 4s???

    How can i delete more then one contact at a time on my iphone 4s or bring my contacts up on itunes on my laptop?? please help

    No.
    Iphone will sync with one and only one computer a a time.  Syncing to another will erase the current content from the iphone and replace with content from the new computer.

  • Defining more then one constant variable to a value

    Is there a way to define more then one value or a wildcard to a variable declaration:
    <p>
    "variable name" := Varchar2 (##) := UPPER ('text') || '<b>value</b>'
    <p>
    I want the value to be more then one value, don't think I can use select....like here,
    Any ideas?
    Message was edited by:
    user452863

    Hi,
    SQL> create or replace procedure tt (invar1 in varchar2, invar2 in varchar2)
      2  as
      3  var varchar2(10):=upper(invar1)||','||upper(invar2);
      4  begin
      5  dbms_output.put_line(var);
      6  end;
      7  /
    Procedure created.
    SQL> exec tt('titi','toto');
    TITI,TOTO
    PL/SQL procedure successfully completed.
    SQL> Is it do you want ?
    Nicolas.

  • MVC - More then one view managed by the same contrler.

    Ok, I have been reading and searching examples on the MVC .. but all the examples show just what to do when you have just one view of the model. What I f I have the more the n one view to handle the same model.
    As we know the views would need to be registerd inside the controler? How can I do this If I have more then one view?
    does anyone have any ideas!?
    Would it still be correct if when an action occures on my view instead of the controler capturing that event an handiling, I make my view call the controler to handle it?

    So in your opinion is it ok if I call my controler from the action event of my button?
    I just did a small example below:
    import java.awt.event.ActionEvent;
    import javax.swing.*;
    import java.awt.event.ActionListener;
    public class Starter extends JFrame{
         private Model myModel = new Model();
         private Controler myControler = new Controler(myModel);
         public Starter(){
              JButton myButton = new JButton("Test");
              myButton.addActionListener(new ActionListener(){
                   public void actionPerformed(ActionEvent e){
                        myControler.makeAction("Hello");
              this.getContentPane().add(myButton);
              this.pack();
              this.show();
         public static void main(String[] args){
              new Starter();
    }As you can see I am calling the controler to manage the new data from the action event of 'myButton' !
    Is the above code ok with the spirit of the MVC?

  • Purchased music on more then one iPod?

    I'm traveling and purchased music for my laptop computer which is usually used for my daughter's iPod Shuffle. How do I put the purchased music on my iPod without replacing the music library from my home computer with the library from my laptop? The laptop iTunes recognizes my iPod but won't let me drag the songs to it.
    Put another way, can I play the purchased songs on more then one iPod?

    Does this help?
    Using iPod with multiple computers
    http://docs.info.apple.com/article.html?artnum=61675

  • How do I get the text to flow throughout more then one page.

    Hello,
    I am currently using LiveCycke Designer to create a scholarship for my company. I created fields for the form and I would like to insert a text to describe the scholarship. When I insert the text, it doesn't flow onto the next page. I've tried creating a subform and clicking "flowed" and "allow page breaks within content". I also clicked auto-fit for the height, but it just makes a line. For the text box, I've clicked "Expand to fit on the height". It is also a dynamic XML Form. Is there anything else I should be doing?
    I could always send the file to someone to see if they can figure it out.
    Thank you,
    Natalie

    Thank you so much !
    but the link doesn't seem to work. It says that the URL is not in the correct format for an Acrobat.com document link.
    Natalie
    Date: Wed, 12 May 2010 07:53:12 -0600
    From: [email protected]
    To: [email protected]
    Subject: How do I get the text to flow throughout more then one page.
    Here is the corrected form..Even you you set the Subform type to "Flowed" to the subform where the Text box resides, you did not set the Page1 to Flowed (which is the key)..But when I make the Page1 type to "Flowed", all your fields above the Scholrship text boxes' Subform will go one below another.. To fix this, first I have select all the fields and wrap them into a subform and then set the Page1 to Flowed..
    https://acrobat.com/#d=XQ1yfV8fCk85M7sRLD*-gg
    Thanks
    Srini
    >

  • HOW DO I USE MORE THEN ONE ITUNES WITH MY IPHONE WITHOUT ERASING MY MUSIC?

    I have two different laptops with iTunes on it. I use both of them but my iPhone only works with one iTunes. I plug it into the computer and it says that my iPhone cannot use more then one iTunes. Is there a way I can use both or no?
    YES I AM CLICKING MANUELLY ADD SONGS TO MY iPhone.
    I just bought my iPhone about a week or so ago.
    Please help ASAP.

    I clone my library to a portable drive using SyncToy 2.1, a free tool from MS. I run this both at home & work so that I essentially have three identical copies of my library for backup redundacy, any of which I can use to update my iPods and my iPhone. I use iTunes Folder Watch occasionaly in case I've managed to download, for example, a podcast at one location but overwrite the library with a newer copy updated at the other. It can be done but you need to take considerable care...
    tt2

  • Can I use more then one apple ID on my computer/osx app store

    Hi,
    I use my MBP/iMac/ipad/iphone for both business and home.  Right now everything is setup to my home apple id (and I have made quite a few purchases with that).  With the release of the osx app store and FCPX,  my company wants to buy these for my computers.  But they want to do this on their apple id.  Can I run more then one id on a mac?  How can I make this work as I know they will want me to start getting more apps as they are released.

    You can have apps from multiple Apple IDs on one Mac. The issue will be that to update Mac apps bought with A ID #1 will require signing into A ID #1 in the MAS. And later when apps bought with A ID #2 need an update you will need to sign into A ID #2 in the MAS to update them. If you can keep that straight and can abide that requirement, there should be no issues.
    The same will be true to update iOS apps, but using iTunes.

  • Since iTunes 7 can't import more then one song at a time

    When I use File> Add file to library, I can no longer import more then one song. If I select more then one file, iTunes wont import anything. I have my music download to my main iTunes folder, therefor I dont want to use add a folder, also there often is other songs I dont want to import at that time. I can drag and drop from explorer, but its annoying.
    Not a terrible bug, but another in the long list for iTunes 7.
    custom   Windows XP Pro   P4 2.8, 1 Gig Ram, Radeon x1600pro, Asus mobo

    Thanks Rachyl, I'll try that when I get off of work. What about the album art? How can I make sure I get it every time in the future. Can I rip my CD's using another software to make sure they are tagged right?
    BTW I used to live in NC not too long ago and went to school there....GO HEELS!

  • Is there a way to Search (List search) for more then one field text from a column for Bulk uploading?

    I've been trying to find more information on this and I apologies if this has already been answered. I just don't know the correct way to ask this. We have a SharePoint List at the company that we have people input information into different columns. The
    problem is most of those information are very repetitive. Is there a way for me to search more then one field text in the column and just input that same information in?
    ex:
    Column 1
    Column 2
    Date:
    883851
    MidWest
    User input 
    8831518
    MidWest
    User input
    On the search field in the SharePoint List, I would need to search for 883851, 8831518 etc,  would view those requested numbers, then I would click edit and change dates to those rows. Does that make sense? I'm sorry I'm fairly new at sharepoint.

    I think what you're asking is about having repetitive options in a list, show up easily for new items being created.
    This can be done by setting the columns that contain repetitive information to Choice fields.  In the configuration of the Choice field, check the box for "Allow custom values".  Now as users are entering data into the list, the dropdown of options
    for a given field grows and users can quickly see and select previously entered and thus repetitive values for the given fields.
    I trust that answers your question...
    Thanks
    C
    |
    RSS |
    http://crayveon.com/blog |
    SharePoint Scripts | Twitter |
    Google+ | LinkedIn |
    Facebook | Quix Utilities for SharePoint

  • More then one student license on same account

    Hello. Can i have more then one student license on same account. The 60% of thingy. One for home, one for work and one for the notebook. They may run simultaneously because of the friends using the computer. All 3 computers will use same account name and password.

    You may install software on up to two computers. These two computers can be Windows, Mac OS, or one each.
    If you install on a third computer, it will request you to de-activate on the other two computers.  You can then reactivate one of the previous two computers, and use Creative Cloud apps on it.
    If you regularly need to use the Creative Cloud on more than two computers then it would be best to purchase an additional subscription.  This is the same licensing btw which we have for our prepetual product.  An advantage though for Creative Cloud over the perpetual product is that you can install on Mac and Windows with the same subscription!
    As it stands, the EULA states that you can install it on up to two computers at a time, however, you cannot use applications on those computers simultaneously. This is the case even when you are not using the same application
    http://www.adobe.com/legal/licenses-terms.edu.html
    Regards
    Rajshree

  • How do I select more then one channel to view in tdms file viewer graph panel

    I have a TDMS file that I can view with the labview 2013 TDMS file viewer and I can select one signal out of 15 signals to view on the graph panel. however I would like be able to look at 2 or 3 signals
    on the same graph but can't seem to be able to select more then one signal at a time. Is there a way to select more then one to view?  

    I've modified the TDMS viewer in the past to allow selecting multple channels.  It's a little bit of a pain because the tree control in the viewer only allows you to select one item.  You have to edit the tree to allow multiple items.  Now your selection is an array instead of a scalar.  This means the rest of the code has to be updated, and the references to the tree in subVIs need to be updated.  Not impossible but it takes some time.  Alternativly open it in Excel with the free add-in then you can select the two columns you want and insert a graph.  Not as simple for the user but using Excel, which users should be familiar with might mean users need less training on data files.
    Unofficial Forum Rules and Guidelines - Hooovahh - LabVIEW Overlord
    If 10 out of 10 experts in any field say something is bad, you should probably take their opinion seriously.

  • Printing salesinvoices, is it possible to do it for more then one invoice?

    Is there a method to use VF03 with a selection for more then one sales invoices?
    I want to print them as pdf file, so I have to fill in the field billingdocument, but I need it for more then one invoice at the same time.
    I tried but it seems not to work. Is it not possible? Or is there another solution to print more then one invoices at the same time?

    Hi,
    check in the Commnication method of your Output type whether In the NUMBER OF MESSAGES field was maintained as 4
    No of messages field will control the Number of invocies to print
    check this and revert
    thanks
    santosh

Maybe you are looking for