Surya Posted December 16, 2019 Share Posted December 16, 2019 I have no idea what regular expressions are: I need to convert this line to AutoIt function Stringregexpreplace() echo <some random characters>| perl -pe 's/\x0D\x0A/\x0A/g' where 's/\x0D\x0A/\x0A/g' is the regular expression I need to convert to Autoit Understandable. No matter whatever the challenge maybe control on the outcome its on you its always have been. MY UDF: Transpond UDF (Sent vriables to Programs) , Utter UDF (Speech Recognition) Link to comment Share on other sites More sharing options...
Danp2 Posted December 17, 2019 Share Posted December 17, 2019 I believe that is just replacing the combination of CR/LF with a LF. There are multiple ways to handle this in Autoit. Show us what you come up with. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Surya Posted December 17, 2019 Author Share Posted December 17, 2019 StringReplace($txt,@CRLF,@LF) doesnt seem to put out required results No matter whatever the challenge maybe control on the outcome its on you its always have been. MY UDF: Transpond UDF (Sent vriables to Programs) , Utter UDF (Speech Recognition) Link to comment Share on other sites More sharing options...
FrancescoDiMuro Posted December 17, 2019 Share Posted December 17, 2019 @Surya Could you please post an input string and the expected result? Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
Surya Posted December 17, 2019 Author Share Posted December 17, 2019 adb screencap -p| perl -pe 's/\x0D\x0A/\x0A/g' and here is the stdout of: adb screencap -p (zipped 2 scrnshots) scrnshot.zip No matter whatever the challenge maybe control on the outcome its on you its always have been. MY UDF: Transpond UDF (Sent vriables to Programs) , Utter UDF (Speech Recognition) Link to comment Share on other sites More sharing options...
Musashi Posted December 17, 2019 Share Posted December 17, 2019 7 hours ago, Danp2 said: I believe that is just replacing the combination of CR/LF with a LF. Yes, it is ! Local $sString $sString = "1Hello " & @LF & " 2brave" & @CRLF & @CRLF & @LF & " 3new" & @CRLF & " 4world" $sString = StringRegExpReplace($sString, "(?>\r\n)", @LF) FileWrite(@ScriptDir & "\Replacetest.txt", $sString) "In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move." Link to comment Share on other sites More sharing options...
Surya Posted December 17, 2019 Author Share Posted December 17, 2019 Thank you @Musashi Don't know why but when I save the output to a png file it doesn't seem to open No matter whatever the challenge maybe control on the outcome its on you its always have been. MY UDF: Transpond UDF (Sent vriables to Programs) , Utter UDF (Speech Recognition) Link to comment Share on other sites More sharing options...
Musashi Posted December 17, 2019 Share Posted December 17, 2019 10 hours ago, Surya said: I need to convert this line to AutoIt function Stringregexpreplace(). [...] where 's/\x0D\x0A/\x0A/g' is the regular expression I need to convert to Autoit understandable. My RegEx above replaces CRLF with LF : Before : After : 1 hour ago, Surya said: Don't know why but when I save the output to a png file it doesn't seem to open I haven't pipe or redirect the output to a png file. BTW : I can't open your graphics either -> decoding error. "In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move." Link to comment Share on other sites More sharing options...
Surya Posted December 17, 2019 Author Share Posted December 17, 2019 The zip file contains the screenshots I captured that needs to be converted, Only after conversion can it be opened No matter whatever the challenge maybe control on the outcome its on you its always have been. MY UDF: Transpond UDF (Sent vriables to Programs) , Utter UDF (Speech Recognition) Link to comment Share on other sites More sharing options...
Malkey Posted December 18, 2019 Share Posted December 18, 2019 This function will open the supplied png image file. However, a lot of the image is transparent which suggests there is more to be done than just changing all 0D0A's to 0A. _Png0D0ATo0A("scrnshot.png", "scrnshotModified.png") ShellExecute("scrnshotModified.png") _Png0D0ATo0A("scrnshot2.png", "scrnshot2Modified.png") ShellExecute("scrnshot2Modified.png") Func _Png0D0ATo0A($sFileNameIn, $sFileNameOut) ;------------------- Read from in file -------------------- Local $hFileOpen = FileOpen($sFileNameIn, 16) ; $FO_BINARY (16) = Force binary mode $b = FileRead($hFileOpen) ;ConsoleWrite($b & @CRLF) $a = StringRegExpReplace($b, "(0D0A)", "0A") FileClose($hFileOpen) ;------------------- Write to out file -------------------- Local $hFileOpenNew = FileOpen($sFileNameOut, 18) ; $FO_BINARY (16) = Force binary mode PLUS $FO_OVERWRITE (2) = Write mode (erase previous contents) FileWrite($hFileOpenNew, $a) ;ConsoleWrite($a & @CRLF) FileClose($hFileOpenNew) EndFunc ;==>_Png0D0ATo0A 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