Jump to content

String Removal Of Comma


Recommended Posts

Hi,

I'm slightly new to AutoIt, though I've used it for several applications, I have come to a problem.

Is there a simple way to take a string "123,456,789" and have it remove the commas and return "123456789"?

It seems it shouldn't be that hard. There's the carriage return removal, but no simple comma remove or even replace.

Thanks

Link to comment
Share on other sites

Hi,

I'm slightly new to AutoIt, though I've used it for several applications, I have come to a problem.

Is there a simple way to take a string "123,456,789" and have it remove the commas and return "123456789"?

It seems it shouldn't be that hard. There's the carriage return removal, but no simple comma remove or even replace.

Thanks

HI,

have a look at StringReplace() and replace "," with ""

So long,

Mega

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

Just to further clarify:

StringReplace("123,456,789",",","")
AutoIt Scripts:Aimbot: Proof of Concept - PixelSearching Aimbot with several search/autoshoot/lock-on techniques.Sliding Toolbar - Add a nice Sliding Toolbar to your next script. Click the link to see an animation of it in action!FontInfo UDF - Get list of system fonts, or search to see if a particular font is installed.Get Extended Property UDF - Retrieve a files extended properties (e.g., video/image dimensions, file version, bitrate of song/video, etc)
Link to comment
Share on other sites

  • Moderators

StringReplace() is definately the way to go here, but if the delimeter is ever different than a comma, and you only want a "Digit" return and don't know what the delimeter is, you could use something like this

$String = '123,456,789'
$Return = _Return_Digits($String)
MsgBox(0, 'Return', $Return)

Func _Return_Digits($s_String)
    Local $iOutput = ''
    For $xcount = 1 To StringLen($s_String)
        $sMid = StringMid($s_String, $xcount, 1)
        If StringIsDigit($sMid) Then $iOutput &= $sMid
    Next
    If $iOutput <> '' Then Return $iOutput
    Return 0
EndFunc

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

SmOke_N, What do you have against StringRegExp? :think:

Global $string = '123,456,789', $finalstring
$temparray = StringRegExp($string, '([:digit:]*)',3)
For $i = 0 to (Ubound($temparray)-1)
$finalstring = $finalstring&$temparray[$i]
Next
Msgbox(0,"Final String",$finalstring)

* Flex *

Edited by Simucal
AutoIt Scripts:Aimbot: Proof of Concept - PixelSearching Aimbot with several search/autoshoot/lock-on techniques.Sliding Toolbar - Add a nice Sliding Toolbar to your next script. Click the link to see an animation of it in action!FontInfo UDF - Get list of system fonts, or search to see if a particular font is installed.Get Extended Property UDF - Retrieve a files extended properties (e.g., video/image dimensions, file version, bitrate of song/video, etc)
Link to comment
Share on other sites

  • Moderators

SmOke_N, What do you have against StringRegExp? :think:

Global $string = '123,456,789', $finalstring
$temparray = StringRegExp($string, '([:digit:]*)',3)
For $i = 0 to (Ubound($temparray)-1)
$finalstring = $finalstring&$temparray[$i]
Next
Msgbox(0,"Final String",$finalstring)

* Flex *

Nothing at all, that's another way of doing it, in fact, yours is probably much faster, but again, StringReplace() would be a better option if the delimeter is known IMHO.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Oh yea.. StringReplace is the solution for him. I was just messing with ya.

Yours looks like it took a lot more thinking to make then mine anyway :think:

AutoIt Scripts:Aimbot: Proof of Concept - PixelSearching Aimbot with several search/autoshoot/lock-on techniques.Sliding Toolbar - Add a nice Sliding Toolbar to your next script. Click the link to see an animation of it in action!FontInfo UDF - Get list of system fonts, or search to see if a particular font is installed.Get Extended Property UDF - Retrieve a files extended properties (e.g., video/image dimensions, file version, bitrate of song/video, etc)
Link to comment
Share on other sites

  • Moderators

Oh yea.. StringReplace is the solution for him. I was just messing with ya.

Yours looks like it took a lot more thinking to make then mine anyway :think:

Nah, took about 30 seconds... helps when you play with strings all the time :(

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

StringRegExp is my new favorite toy. I dont know how I lived without it before.

AutoIt Scripts:Aimbot: Proof of Concept - PixelSearching Aimbot with several search/autoshoot/lock-on techniques.Sliding Toolbar - Add a nice Sliding Toolbar to your next script. Click the link to see an animation of it in action!FontInfo UDF - Get list of system fonts, or search to see if a particular font is installed.Get Extended Property UDF - Retrieve a files extended properties (e.g., video/image dimensions, file version, bitrate of song/video, etc)
Link to comment
Share on other sites

  • Moderators

StringRegExp is my new favorite toy. I dont know how I lived without it before.

I agree, I still use the others, but when I have a large file I'm parsing, I only use that (along with some other string functions) to get my desired result. I'm not biast, I use whatever gets the job done the fastest with the best result :think::(

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

I agree, I still use the others, but when I have a large file I'm parsing, I only use that (along with some other string functions) to get my desired result. I'm not biast, I use whatever gets the job done the fastest with the best result :think::(

HI,

so SmOke_N would you mind posting some of your additional string func. I always like it as easy as it can be and still don't know why some string func existing in other languages haven't found the way into Autoit standard.

Like StringBetween() ...

I knew, everybody can write that hisself, but why?

So long,

Mega

Edited by th.meger

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

  • Moderators

HI,

so SmOke_N would you mind posting some of your additional string func. I always like it as easy as it can be and still don't know why some string func existing in other languages haven't found the way into Autoit standard.

Like StringBetween() ...

I knew, everybody can write that hisself, but why?

So long,

Mega

I meant the String Functions that are in the help file th.meger. Haven't found a need to manipulate outside of those yet.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

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