Copy Paste Code

suppose i have following text in my text file:
the apple is red in color.
and the sun shines in the morning.
now from the above 2 lines suppose i have to select following words in the sequence:
1 . the sun
2 . is red in color
3 . and
4 . shines in the morning.

and paste them to get the sentence:
the sun is red in color and shines in the morning.
what we do is for every word i''l have to first select it and then type ctrl+c to copy and ctrl+v to paste. then again for next selection i do the same copy paste operations.
so now can i write some code which will allow me to select multiple words from different sentences and and copy paste them all together to get a new sentence containing these words in the sequence in which i selected the words while copying?

Replies

  • Manish Goyal
    Manish Goyal
    I am not sure .but i think you can create some Macro using MS word for this purpose
  • slashfear
    slashfear
    Hi Poovadate,

    I guess if you know perl or any other language which supports regular expressions like python or java we can do this task in a simple way!! (I am not good in java 😔 ) I am going to show you how to do it perl (sorry for the shabby code was in a hurry to write it......)

    Lets say the content is in the file named "samp.txt",

    the apple is red in color
    and the sun shines in the morning
    
    The program to manipulate it would be something like this,

    open(FILE, "samp.txt");
    
    while()
    {
    if($_ =~ s/apple/sun/ || $_ =~ s/the sun//)
    {
    print $_ . "\n";
    
    }
    
    }
    
    
    Basically i am using substitution regular expression to substitute apple with sun and the sun with nothing 😀 simple...........!! (Hope this is what you wanted!!)


    If you have any questions, please feel free to ask back.....


    -Arvind
  • Deepika Bansal
    Deepika Bansal
    Great idea of using programming for this concept. Adding more features, we can make it generic as well.

You are reading an archived discussion.

Related Posts

Recently, Google demonstrated the newer version of the Android series, Android Honeycomb 3.0. The demo of the new OS was given on Motorola’s* Xoom tablet which is soon to be...
Today, I read a news about Nokia introducing a bicycle mobile charger in India in March this year. If you are an Eco-friendly person and believe in energy saving concept,...
Found this article while surfing. I thought I should share it with you. Two incidents drove me to write this article. In the first incident, a woman wished that her...
Everyone is aware of the fact that Doctors take pledge/oath when they graduate. But we as engineers don't take any such pledge or oath. Let's create our own "Engineers' Pledge"....
Experience the cultural extravaganza at SHRI RAMDEOBABA KAMLA NEHRU ENGINEERING COLLEGE kick starting from 3rd feb. Feel the symphony in the cultural atmosphere. New events like paintball, zorbing, boxcricket any...