Jump to content
Sign in to follow this  
Clever1mba

StringReplace

Recommended Posts

Clever1mba

Hi

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

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

Share this post


Link to post
Share on other sites
w0uter

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

Share this post


Link to post
Share on other sites
Clever1mba

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

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

Share this post


Link to post
Share on other sites
Clever1mba

if anyone have solution for stringreplace then plz kindly share it

Share this post


Link to post
Share on other sites
Nutster

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

Share this post


Link to post
Share on other sites
FuryCell

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

Share this post


Link to post
Share on other sites
buzz44

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

Share this post


Link to post
Share on other sites
FuryCell

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.

Share this post


Link to post
Share on other sites
jimbeaurama

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

Share this post


Link to post
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
Sign in to follow this  

×