jorgeng Posted April 27, 2010 Posted April 27, 2010 I am trying to replace text in string but it doesn't work. What's wrong? The only replace which works is '00$' to blank. $s_string = '09:15 ORDER "sl) Omx Sarlacc - Köp Trade - Grön - Krypterat OMXS300E" kurs 1063.5000$' $text = StringReplace($s_string, '""', "") $text = StringReplace($s_string, "sl)", "") $text = StringReplace($s_string, "Krypterat", "") $text = StringReplace($s_string, "ORDER", "") $text = StringReplace($s_string, '00$', "") MsgBox(4096,"Box",$text)
Fire Posted April 27, 2010 Posted April 27, 2010 You want get result like this? 09:15 Omx Sarlacc - Kop Trade - Gron - OMXS300E kurs 1063.50 $s_string = "09:15 ORDER ""sl)"" Omx Sarlacc - Kop Trade - Gron - Krypterat OMXS300E kurs 1063.5000$" $text = StringReplace($s_string, '""""', "") $text = StringReplace($text, """sl)""", "") $text = StringReplace($text, "Krypterat", "") $text = StringReplace($text, "ORDER", "") $text = StringReplace($text, '00$', "") MsgBox(4096,"Box",$text) [size="5"] [/size]
jorgeng Posted April 27, 2010 Author Posted April 27, 2010 You want get result like this? 09:15 Omx Sarlacc - Kop Trade - Gron - OMXS300E kurs 1063.50 $s_string = "09:15 ORDER ""sl)"" Omx Sarlacc - Kop Trade - Gron - Krypterat OMXS300E kurs 1063.5000$" $text = StringReplace($s_string, '""""', "") $text = StringReplace($text, """sl)""", "") $text = StringReplace($text, "Krypterat", "") $text = StringReplace($text, "ORDER", "") $text = StringReplace($text, '00$', "") MsgBox(4096,"Box",$text) Thanks. I tried but it doesn't makes what i want. The string: $s_string = '09:15 ORDER "sl) Omx Sarlacc - Köp Trade - Grön - Krypterat OMXS300E" kurs 1063.5000$' is automatically generated from a ta-program and i can't change the double dots from input-file. The result when i run your code with input from the ta-program is: 09:15 "sl) Omx Sarlacc - Köp Trade - Grön - Krypterat OMXS300E" kurs 1063.50 Be aware of the double dots. Any idea?
GEOSoft Posted April 27, 2010 Posted April 27, 2010 2 ways. First off your code is wrong $s_string = "09:15 ORDER ""sl)"" Omx Sarlacc - Kop Trade - Gron - Krypterat OMXS300E kurs 1063.5000$" $text = StringReplace($s_string, '"', "") $text = StringReplace($text, "sl)", "") $text = StringReplace($text, "Krypterat", "") $text = StringReplace($text, "ORDER", "") $text = StringReplace($text, "00$", "") MsgBox(4096,"Box",$text) Beter yet $s_string = "09:15 ORDER ""sl)"" Omx Sarlacc - Kop Trade - Gron - Krypterat OMXS300E kurs 1063.5000$" $sText = StringRegExpReplace($s_String, "(?i)sl\)|\x22|krypterat|\bORDER\b|00\$", "") MsgBox(4096,"Box",$text) That will return 09:15 Omx Sarlacc - Köp Trade - Grön - OMXS300E kurs 1063.50 from your example George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!"
Fire Posted April 27, 2010 Posted April 27, 2010 Ok $s_string = '09:15 ORDER "sl) Omx Sarlacc - Kop Trade - Gron - Krypterat OMXS300E" kurs 1063.5000$' ;$s_string = "09:15 ORDER ""sl)"" Omx Sarlacc - Kop Trade - Gron - Krypterat OMXS300E kurs 1063.5000$" $text = StringReplace($s_string, """", "") $text = StringReplace($text, "sl)", "") $text = StringReplace($text, "Krypterat", "") $text = StringReplace($text, "ORDER", "") $text = StringReplace($text, "00$", "") MsgBox(4096,"Box",$text) ;FileWrite(@ScriptDir&"\datad4.txt",$text) ;uncomment it for get result in datad4.txt file. It returns me: 09:15 Omx Sarlacc - Kop Trade - Gron - OMXS300E kurs 1063.50 [size="5"] [/size]
jorgeng Posted April 27, 2010 Author Posted April 27, 2010 (edited) 2 ways. First off your code is wrong $s_string = "09:15 ORDER ""sl)"" Omx Sarlacc - Kop Trade - Gron - Krypterat OMXS300E kurs 1063.5000$" $text = StringReplace($s_string, '"', "") $text = StringReplace($text, "sl)", "") $text = StringReplace($text, "Krypterat", "") $text = StringReplace($text, "ORDER", "") $text = StringReplace($text, "00$", "") MsgBox(4096,"Box",$text) Beter yet $s_string = "09:15 ORDER ""sl)"" Omx Sarlacc - Kop Trade - Gron - Krypterat OMXS300E kurs 1063.5000$" $sText = StringRegExpReplace($s_String, "(?i)sl\)|\x22|krypterat|\bORDER\b|00\$", "") MsgBox(4096,"Box",$text) That will return 09:15 Omx Sarlacc - Köp Trade - Grön - OMXS300E kurs 1063.50 from your example Thanks, that code was heavy, didn't get it to work. Edited April 27, 2010 by jorgeng
jorgeng Posted April 27, 2010 Author Posted April 27, 2010 Ok $s_string = '09:15 ORDER "sl) Omx Sarlacc - Kop Trade - Gron - Krypterat OMXS300E" kurs 1063.5000$' ;$s_string = "09:15 ORDER ""sl)"" Omx Sarlacc - Kop Trade - Gron - Krypterat OMXS300E kurs 1063.5000$" $text = StringReplace($s_string, """", "") $text = StringReplace($text, "sl)", "") $text = StringReplace($text, "Krypterat", "") $text = StringReplace($text, "ORDER", "") $text = StringReplace($text, "00$", "") MsgBox(4096,"Box",$text) ;FileWrite(@ScriptDir&"\datad4.txt",$text) ;uncomment it for get result in datad4.txt file. It returns me: 09:15 Omx Sarlacc - Kop Trade - Gron - OMXS300E kurs 1063.50 Thanks, now it works.
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