Forum Discussion

Kamal_K's avatar
Kamal_K
New Contributor
12 years ago

Copy the Seperate Text from Clipboard

Hi,

i have an issue while copy the Text from clipboard, Clipboard has the text like "Hi How Are you", i need to select and copy the seperate text " How Are" also dnt want to use Position or Index to select and copy the seperate text file, In "JScript" is there ant way to do that?







Thanks

4 Replies

  • murugans1011's avatar
    murugans1011
    Regular Contributor
    do u mean somethin lik this



    function testString()



    {

    var ClipString = ("Hi How are you");

     

    var arrSplit = ClipString.split(" ");



    Log.Message(arrSplit[1] + " " + arrSplit[2]);



    }
  • Not sure about Jscript. But with VBScript I use "instr" to find the start location of the text I want and then use that to extract the chunk I want from the larger text string.



    I do this from the clipboard quite often when checking documents, e-mails etc.



    It's pretty simple. I assume Jscript must offer something similar?
  • Kamal_K's avatar
    Kamal_K
    New Contributor
    Hi Colin,

    Can you please  eloborate little bit more
  • Remember, this is using VBScript ...



    So ...



    http://msdn.microsoft.com/en-us/library/wybb344c.aspx



    instr returns the start point where one string occurs within another (so finding "ghi" within "abcdefghijklm" would return 7. I know "ghi" is 3 characters long (using "len" in VBScript).



    So now I know how long it is and where it starts I can do what I need to do with it.



    Extract it, replace it, report the start point .... or whatever.



    You'll need to work out the Jscript equivalents for instr & len. I don't know Jscript so can't help you there I'm afraid.