StringReplace: How do I also include commas?

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
User avatar
GalaxyMan
Junior Coder
Posts: 40
Joined: Sat Jun 27, 2009 7:21 pm

StringReplace: How do I also include commas?

Post by GalaxyMan » Wed Mar 02, 2011 8:39 am

:roll: I've got tables of information. Some of the cells are not properly formatted. They are displaying numbers instead of properly formatted currency. 150000 instead of $150,000. Sometimes it's 150000. when it needs to be $150,000.

I have to use the tags in the definition because of the various similar permutations of the same number.

For some reason if I use these as parameters in a StringReplace statement, nothing happens. I assume it's something to do with the 'special' characters such as the ($) and/or the (,) but I just can't seem to figure it out.

Any help would be very much appreciated.

Thanks in advance...

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Wed Mar 02, 2011 9:05 am

Let>comma=,
StringReplace>some_string,comma,replacement,new_string
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

User avatar
GalaxyMan
Junior Coder
Posts: 40
Joined: Sat Jun 27, 2009 7:21 pm

Post by GalaxyMan » Wed Mar 02, 2011 9:31 am

Hi, Marcus.

I tried your suggestion. This is the actual lines of code that I'm trying to work with. I wasn't sure whether to use the Let> before each line or not, so I started by trying it just once before them all. Here is the actual code I'm using.

Let>comma=,
StringReplace>theFileData,150000,$150comma000,theFileData
StringReplace>theFileData,$150000,$150comma000,theFileData
StringReplace>theFileData,150000.,$150comma000,theFileData
StringReplace>theFileData,150comma000,$150comma000,theFileData

The first 3 StringReplace> commands resulted in this:

$150comma000

The 4th one in this:

150,000


Is there any sort of 'bracketing' that can go around the Source and/or the Result data so that any punctuation, or anything but the actual characters/character spaces will be seen and not their inherent values? Sort of like "Source","Result". Would it be % like with commands (%CRLF%)?

Thanks again.

Ronen Ben-Hai
Zutphen, Netherlands

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Wed Mar 02, 2011 11:18 am

You need:

StringReplace>theFileData,150000,$150%comma%000,theFileData

Please see the user guide section on using variables.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

User avatar
GalaxyMan
Junior Coder
Posts: 40
Joined: Sat Jun 27, 2009 7:21 pm

Post by GalaxyMan » Wed Mar 02, 2011 12:38 pm

That did the trick! Thanks for the guidance. And I promise you, I searched for an answer to this before posting for help. I prefer working things out myself, but when I can't... 8)

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts