Jump to content
Sign in to follow this  
jorgeng

Replace won't work

Recommended Posts

jorgeng

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.

:idea:

$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)

Share this post


Link to post
Share on other sites
Fire

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]

Share this post


Link to post
Share on other sites
jorgeng

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?

:idea:

Share this post


Link to post
Share on other sites
GEOSoft

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!"

Share this post


Link to post
Share on other sites
Fire

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]

Share this post


Link to post
Share on other sites
jorgeng

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.

:idea:

Edited by jorgeng

Share this post


Link to post
Share on other sites
jorgeng

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.

:idea:

Share this post


Link to post
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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.