Jump to content

StringReplace


Recommended Posts

Hi

when i using multi replacestring its not working but when i put only one replacestring then it works how to use multi replacestrings?

<{POST_SNAPBACK}>

i am unclear what you are trying to do. got a snippet and some explaination ?

My UDF's:;mem stuff_Mem;ftp stuff_FTP ( OLD );inet stuff_INetGetSource ( OLD )_INetGetImage _INetBrowse ( Collection )_EncodeUrl_NetStat_Google;random stuff_iPixelSearch_DiceRoll

Link to comment
Share on other sites

okay

check this code i want to replace multi replacestring like

notepad.exe,lantalk.exe,etc

but only single replacestring works

$out=""

$list = ProcessList()

for $i= 1 to $list[0][0]

$out=  $out & $list[$i][0]& ","

Next

$text = StringReplace($out, "notepad.exe", "-")

MsgBox(0, "Test", $text)

hope u get my point

------------------------

Link to comment
Share on other sites

According to the documentation, you can add a count, for the number of occurances to replace. For example,

$words = "This is a test."
$find = "is"
$new = "was"
$result = StringReplace ( $Words, $find, $new , 0 )

A count (the optional number at the end of the StringReplace function) says how many occurances are to be replaced. A number 1 or greater indicates that the replacements should start on the left side of the string. A number of -1 or less indicates that the replacements should starts on the right side of the string. Using 0, as I did, says to do unlimited replacements.

Does this help?

David Nuttall
Nuttall Computer Consulting

An Aquarius born during the Age of Aquarius

AutoIt allows me to re-invent the wheel so much faster.

I'm off to write a wizard, a wonderful wizard of odd...

Link to comment
Share on other sites

$text = StringReplace($out, "autoit1.exe,autoit2.exe", "-")

just looked at the manual. From what i read it dosent seem that StringReplace() supports multiple searchstrings. :)

why not try this instead:

$text = StringReplace($out, "autoit1.exe", "-")
$text = StringReplace($out, "autoit2.exe", "-")
Edited by SolidSnake
HKTunes:Softpedia | GoogleCodeLyricToy:Softpedia | GoogleCodeRCTunes:Softpedia | GoogleCodeMichtaToolsProgrammer n. - An ingenious device that turns caffeine into code.
Link to comment
Share on other sites

Or you could just cram it all into 'one' command. Or you could make a simple function to do this for you...

$Out = "/autoit1.exe\ << some test >> /autoit2.exe\"
$Text = StringReplace(StringReplace($Out, "autoit1.exe", "-"), "autoit2.exe", "-")
MsgBox(0,"Result",$Text)

And SolidSnake I think you had a small typo in yours...

$text = StringReplace($out, "autoit1.exe", "-")
$text = StringReplace($text, "autoit2.exe", "-")

qq

Link to comment
Share on other sites

Or you could just cram it all into 'one' command. Or you could make a simple function to do this for you...

$Out = "/autoit1.exe\ << some test >> /autoit2.exe\"
$Text = StringReplace(StringReplace($Out, "autoit1.exe", "-"), "autoit2.exe", "-")
MsgBox(0,"Result",$Text)

And SolidSnake I think you had a small typo in yours...

$text = StringReplace($out, "autoit1.exe", "-")
$text = StringReplace($text, "autoit2.exe", "-")

<{POST_SNAPBACK}>

Good idea about cramming it into one command and sorry about the typo. :">
HKTunes:Softpedia | GoogleCodeLyricToy:Softpedia | GoogleCodeRCTunes:Softpedia | GoogleCodeMichtaToolsProgrammer n. - An ingenious device that turns caffeine into code.
Link to comment
Share on other sites

  • 4 weeks later...

Or you could just cram it all into 'one' command. Or you could make a simple function to do this for you...

$Out = "/autoit1.exe\ << some test >> /autoit2.exe\"
$Text = StringReplace(StringReplace($Out, "autoit1.exe", "-"), "autoit2.exe", "-")
MsgBox(0,"Result",$Text)

And SolidSnake I think you had a small typo in yours...

$text = StringReplace($out, "autoit1.exe", "-")
$text = StringReplace($text, "autoit2.exe", "-")

<{POST_SNAPBACK}>

:DAWESOME!!! :)

THANK YOU!

THANK YOU!

THANK YOU!

:evil::D

I have been working on this very issue for 3 days now. I put your nested command into my script and had it working in seconds. The good news is that I actually kind of understand Autoitscript now. Incredible utility.

:mad::D

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...