Jump to content

Replace text after a string


legend
 Share

Recommended Posts

I suppose that you know SourceFiles0= so. Why not add new string to that.

 

Saludos

Link to comment
Share on other sites

$var="SourceFiles0=C:\Users\flox\Desktop\build\"
$iCnt = StringLen("SourceFiles0=")
ConsoleWrite("$iCnt =  " & $iCnt & @CRLF)
$varCut = StringLeft($var, $iCnt)
ConsoleWrite("$varCut =  " & $varCut & @CRLF)
$newString =  $varCut & " Something Else"
ConsoleWrite("$newString =  " & $newString & @CRLF)

 

Link to comment
Share on other sites

I need to replace a string in a file.

so I need to replace: 

SourceFiles0=C:\Users\flox\Desktop\build\

with just: 

SourceFiles0=

 

(I don't know at what line number SourceFiles0=C:\Users\flox\Desktop\build\) are

Edited by legend
Link to comment
Share on other sites

something like:

Local $aFile=FileReadToArray("file.txt")


For $i=0 to UBound($aFile)-1
   If StringInStr($aFile[$i],"SourceFiles0=") Then
      $aFile[$i]="SourceFiles0=" & "Replacestringhere"
   EndIf
   FileWrite("newfile.txt",$aFile[$i] & @CRLF)
Next

Saludos

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