Jump to content

copy the entire line containing the string "Business Name"


Recommended Posts

WinActivate ("script.txt - Notepad")

$Text = "Business Name"

$Position = StringInStr($Text, " ")

MsgBox(0, "trimmed text 2", StringTrimLeft($Text, $Position))

I would like the script to copy the entire line containing the string "Business Name" and remove "Business Name" to leave only titles.

origanal Business Name Test Business

removed Test Business

i do not want a msgbox

Please help Thanks

Link to comment
Share on other sites

WinActivate ("script.txt - Notepad")

$Text = "Business Name"

$Position = StringInStr($Text, " ")

MsgBox(0, "trimmed text 2", StringTrimLeft($Text, $Position))

I would like the script to copy the entire line containing the string "Business Name" and remove "Business Name" to leave only titles.

origanal Business Name Test Business

removed Test Business

i do not want a msgbox

Please help Thanks

StringInStr() gives the position of the first character in the match. To skip over the matching string, you want to add StringLen() to the position.

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

well... just get the notepad's window text

make a stringsplit($string, @crlf)

loop it checking for the string you want to search ($text)

remove $text

create a new file with the new value and start it in notepad

Some Projects:[list][*]ZIP UDF using no external files[*]iPod Music Transfer [*]iTunes UDF - fully integrate iTunes with au3[*]iTunes info (taskbar player hover)[*]Instant Run - run scripts without saving them before :)[*]Get Tube - YouTube Downloader[*]Lyric Finder 2 - Find Lyrics to any of your song[*]DeskBox - A Desktop Extension Tool[/list]indifference will ruin the world, but in the end... WHO CARES :P---------------http://torels.altervista.org

Link to comment
Share on other sites

I have copied the text from an IE page to notepad.

I wish to copy the Entire Line containing the String "Business name" and past it into another notepad.

The String "Business name" will then be removed.

Would the above be easy to copy from the origanal IE page. if so how.?

Thanks

Link to comment
Share on other sites

I have copied the text from an IE page to notepad.

I wish to copy the Entire Line containing the String "Business name" and past it into another notepad.

The String "Business name" will then be removed.

Would the above be easy to copy from the origanal IE page. if so how.?

Thanks

Link to comment
Share on other sites

I have copied the text from an IE page to notepad.

I wish to copy the Entire Line containing the String "Business name" and past it into another notepad.

The String "Business name" will then be removed.

Would the above be easy to copy from the origanal IE page. if so how.?

Thanks

Link to comment
Share on other sites

  • Moderators

I have copied the text from an IE page to notepad.

I wish to copy the Entire Line containing the String "Business name" and past it into another notepad.

The String "Business name" will then be removed.

Would the above be easy to copy from the origanal IE page. if so how.?

Thanks

Local $sText = Your string to search here
Local $sStringToFind = "Business Name"
Local $aSRE = StringRegExp($sText, "(?i)\n(.*?" & $sStringToFind & ".*?)(?m:$|\r)", 1)
If IsArray($aSRE) Then MsgBox(64, "Info", $aSRE[0])
That might work.

Edit:

Or if I misunderstood you, you may only need StringReplace or StringRegExpReplace once you have the main string to replace the specific string "Business Name"

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

I have copied the text from an IE page to notepad.

I wish to copy the Entire Line containing the String "Business name" and past it into another notepad.

The String "Business name" will then be removed.

Thanks

Something like this may work for you:

this is a sample "script.txt" file that holds your source and should be open in notepad

Businesss Name  Test Business
President's Name Joe Blow

And this is the script to run against it

WinActivate ("script.txt - Notepad")
$originalText = ControlGetText("script.txt - Notepad","","Edit1")
;MsgBox(0,"",$originalText)
$TextToStrip = "Business Name"
$strippedText = StringReplace($originalText,$textToStrip,"") ;replace "Buisness Name" with nothing, removing it
$strippedText = StringStripWS($strippedText,3) ;trim leading and trailing whitespace
;MsgBox(0,"",$strippedText)
$changedFile = FileOpen("ScriptChanged.txt",2) ;open a file for writing, erasing previous contents
FileWrite($changedFile,$strippedText) ;write the changed text to the file
FileClose($changedFile) ; close the changed file for writing
Run("notepad.exe ScriptChanged.txt") ; run notepad and open the changed file

Of course I'm sure your "script.txt" file is more complex than that simple example, but it should give you the idea.

Would the above be easy to copy from the origanal IE page. if so how.?

It could be very easy, or maybe not :)

Perhaps the _IE functions could help or InetGet().

Without seeing the page or a sample of the source hard to say what would be the best way.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...