Replacing String in a text file
-
Recently Browsing 0 members
No registered users viewing this page.
-
Similar Content
-
By ShupDogg
I am looking for a script to replace the string in 2 different files types.
I have .hod files and .ws files. These are AS/400 Session file types.
If you open the files with a text editor you can change the Host they are connecting to.
I need to change if needed to a Standard Host name.
.HOD file has a line host=X.X.X.X or something of the sort and I need it to be host=DNSName
.WS file has a line HostName=X.X.X.X and needs to be HostName=DNSName
It would be nice to be able to run this script silently on the PC if running with a switch (can do with software deployment) and if a person wanted to run it manually they would get a pop-up on how many it changed. The bad thing is these files could be in quite a few different places on the PC. If I could put in the script the most common places to look for the files that would be good to. I also just found out that if the session is open and you change the string, when you close the session it changes the string back to what it was. I guess maybe error with "sessions need to be closed" if there is a certain exe running.
Thank you in advanced for any help you can provide.
-
By cdeb
As for the object, in this case the StringReplace() function does not work for me.
These are my steps:
1) Extract the subject from an EML file.
(the first character is an emoji )
source from EML file:
$sSubject = "?utf-8?B?8J+TiCA1IG9mIHRoZSBCZXN0IFN0b2NrcyB0byBCdXkgZm9yIERlY2VtYmVy?=" 2) in this case I perform a decoding with _QuotedPrintable_DecodeEncodedWord()
output is:
$sSubject = "?? 5 of the Best Stocks to Buy for December"
3) I perform StringReplace():
$sSubject = StringReplace($sSubject, "??", "") or
$sSubject = StringReplace($sSubject, Chr(63)&Chr(63), "")
But the characters ?? they are not replaced.
Yet if I make an Asc of every character of the string with a for loop, are the first two characters really? that is 63
For cycle
Local $aArray = StringSplit($sSubject, "", $STR_NOCOUNT) For $i = 0 To UBound($aArray)-1 ConsoleWrite($aArray[$i] & " - " & Asc($aArray[$i])& @CR) Next Output:
? - 63
? - 63
- 32
5 - 53
- 32
o - 111
f - 102
- 32
t - 116
h - 104
e - 101
- 32
Does anyone have an explanation of why it doesn't work?
Thank you all
-
By jmp
I am adding labour charge to total paid amount using :
#include <IE.au3> #include <Array.au3> $oIE = _IEAttach ("Shop") $oTable = _IETableGetCollection ($oIE, 1) $aTableData3 = _IETableWriteToArray ($oTable) Local $sitem1 = $aTableData3[5][1] Local $sitem2 = $aTableData3[5][2] Local $lcharge = "10" ;add manualy using inputbox, becuase not generating online Local $atotPric = "Payable Total Price " Local $oTds = _IETagNameGetCollection($oIE, "td") For $oTd In $oTds If $oTd.Innertext = $atotPric Then $iatotPric = $oTd.NextElementSibling.innertext MsgBox (0, "2", $iatotPric) EndIf Next $irCtotal = StringFormat("%.2f", $sitem1 + $sitem2 + $lcharge) $crTotp = StringReplace(_IEBodyReadHTML($oIE), $iatotPric, $irCtotal) _IEBodyWriteHTML ($oIE, $crTotp) But, It was also changing Total price, I want to change only Payable Total Price.
-
By dascondor
So basically need to pull text from a .txt file or .sql and use that text to replace something within a different file.
First File:
jumps
Or:
Text1 = jumps
Text2 = fence
Second File:
My Dog XXXXX over the YYYYY.
After Script:
My Dog jumps over the fence
I have found a good start, I'm basic programmer at best, I have some experience but this gets out of my wheel house.
Any help is appreciated.
-
By milos83
Default keyword for optional parameter is interpreted wrongly.
ConsoleWrite(StringReplace("aa", "a", "b", Default, 1) & @CRLF) StringReplace ( "string", "searchstring/start", "replacestring" [, occurrence = 0 [, casesense = 0]] ) The code above will output ab even thou the default value for the occurrence is 0 (replace all).
Of course using zero instead of Default will work fine.
-
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