Jump to content

Cut zeroes


Recommended Posts

I have a string in a file which is like this:

17:24 ORDER "sl) Omx Sarlacc - Nollställ Depå - Krypterat OMXS300F" kurs 1045.7500$

I want to cut two zeroes after the price meaning i want the string to look like this:

17:24 ORDER "sl) Omx Sarlacc - Nollställ Depå - Krypterat OMXS300F" kurs 1045.75$

I write the string to a file today by doing this and want now to write the file without

four digits, just two digits, anyone having an idea how to cut two digits?

FileDelete("C:\Filer\Rankor System\Omx_Sarlacc_Trades_PHP_Mangold.txt")

$file_Omx_Sarlacc_PHP_Mangold = FileOpen("C:\Filer\Rankor System\Omx_Sarlacc_Trades_PHP_Mangold.txt", 1)

;Check if file opened for writing OK

If $file_Omx_Sarlacc_PHP_Mangold = -1 Then

MsgBox(4096, "Error", "Unable to open file Omx_Sarlacc_PHP_Mangold.",2)

Exit

FileWrite($file_Omx_Sarlacc_PHP_Mangold, $var_original)

;MsgBox(4096, "Trade", $file_Omx_Sarlacc_PHP_Mangold)

FileClose($file_Omx_Sarlacc_PHP_Mangold)

Link to comment
Share on other sites

Here my suggestion:

$line = '17:24 ORDER "sl) Omx Sarlacc - Nollställ Depå - Krypterat OMXS300F" kurs 1045.7500$'

$aStrReg = StringRegExp($line, ".+kurs ([\d].+)", 3)
$new = Round(StringLeft($aStrReg[0], StringLen($aStrReg[0]) - 1), 2) & "$"
$line = StringReplace($line, $aStrReg[0], $new)

ConsoleWrite($line & @CRLF)

BR,

UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

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