n9mfk9 Posted July 13, 2007 Share Posted July 13, 2007 HI all I am stuck here here is my test code $test5 = "test" & @CR &"test" & @CR &"test" $test6 = StringInStr($test5,"test",0,3) StringReplace ($test6,"ok",1) MsgBox(0,"test5",$test5) what i went to do is change the 3rd test to ok an not change the first or second thanks beau Link to comment Share on other sites More sharing options...
Developers Jos Posted July 13, 2007 Developers Share Posted July 13, 2007 $test5 = "test" & @CR & "test" & @CR & "test" $test6 = StringInStr($test5, "test", 0, 3) If $test6 Then $test5 = StringLeft($test5,$test6-1) & "ok" & StringMid($test5,$test6 + 4) EndIf MsgBox(0, "test5", $test5) SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted July 13, 2007 Moderators Share Posted July 13, 2007 (edited) Func _StringReplaceInstance($sString, $sReplace, $sReplaceWith, $iInstance, $iCase = 0) Local $iSnS = StringInStr($sString, $sReplace, $iCase, $iInstance) If $iSnS = 0 Then Return SetError(1, 0, '') Return StringLeft($sString, $iSnS -1) & $sReplaceWith & StringTrimLeft($sString, $iSnS + (StringLen($sReplace) - 1)) EndFunc Edit Hmm... I didn't even notice that Jdeb had responded 10 minutes ago!! (Senility?) Edited July 13, 2007 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 More sharing options...
n9mfk9 Posted July 13, 2007 Author Share Posted July 13, 2007 Func _StringReplaceInstance($sString, $sReplace, $sReplaceWith, $iInstance, $iCase = 0) Local $iSnS = StringInStr($sString, $sReplace, $iCase, $iInstance) If $iSnS = 0 Then Return SetError(1, 0, '') Return StringLeft($sString, $iSnS -1) & $sReplaceWith & StringTrimLeft($sString, $iSnS + (StringLen($sReplace) - 1)) EndFunc Edit Hmm... I didn't even notice that Jdeb had responded 10 minutes ago!! (Senility?)Hi the both worked there was one thing once i do the 3rd 1 i went to do every on from there on how wood i do it Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted July 13, 2007 Moderators Share Posted July 13, 2007 (edited) Hi the both worked there was one thing once i do the 3rd 1 i went to do every on from there on how wood i do itYou've been here for how long? Something like:$sTemp = $sString While 1 $sString = _StringReplaceInstance($sString, 'test', 'ok', 3) If @error Then ExitLoop $sTemp = $sString WEnd $sString = $sTemp Func _StringReplaceInstance($sString, $sReplace, $sReplaceWith, $iInstance, $iCase = 0) Local $iSnS = StringInStr($sString, $sReplace, $iCase, $iInstance) If $iSnS = 0 Then Return SetError(1, 0, '') Return StringLeft($sString, $iSnS -1) & $sReplaceWith & StringTrimLeft($sString, $iSnS + (StringLen($sReplace) - 1)) EndFunc? Edit: the example I had wouldn't work... from before. Edit2: It would be much simpler if we used StringRegExpReplace... but I didn't figure out the right syntax for it. Edited July 13, 2007 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 More sharing options...
n9mfk9 Posted July 13, 2007 Author Share Posted July 13, 2007 (edited) the example from before wood only do the 3rd line i was try to start at 3rd line an replace every line there an after I was thinking StringRegExpReplace but could not fat a way for it to start on the 3rd line Edited July 13, 2007 by n9mfk9 Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted July 13, 2007 Moderators Share Posted July 13, 2007 the example from before wood only do the 3rd line i was try to start at 3rd line an replace every line there an afterDid you bother to run the above? Sometimes I wonder where in the hell this forum is going... from stupid ass titles with no descriptions to people that put forth no effort on their own (or if they do they don't show it). 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 More sharing options...
n9mfk9 Posted July 13, 2007 Author Share Posted July 13, 2007 thanks for all the help that did it Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now