acantor Posted November 23, 2013 Report Share Posted November 23, 2013 One of my scripts copies information to the clipboard, then copies the clipboard to a text variable for further processing. After several manipulations, I need to know the number of commas in the text variable. Is there a straightforward way to do this in MEP? I found a solution, but there must be a simpler way! See below. My approach involves 45 or 50 lines of code that incrementally replace every character, except commas, with nothing. I am left with a text variable that consists only of commas, so I get the answer by asking for the length of the string variable: Variable Modify String: Replace "a" in %Text% with "" Variable Modify String: Replace "b" in %Text% with "" Variable Modify String: Replace "c" in %Text% with "" etc. Variable Modify String: Replace "1" in %Text% with "" Variable Modify String: Replace "2" in %Text% with "" Variable Modify String: Replace "3" in %Text% with ""etc. Variable Modify String: Replace "-" in %Text% with "" Variable Modify String: Replace "." in %Text% with "" Variable Modify String: Replace "(" in %Text% with "" etc. Variable Set Integer %NumberOfCommas% to the length of variable %Text% Quote Link to comment Share on other sites More sharing options...
Cory Posted November 23, 2013 Report Share Posted November 23, 2013 What I do is copy the sting to a temp var then replace all occurances in that var with nothing. Then subtract the length of it from there length of the original var. Quote Link to comment Share on other sites More sharing options...
paul Posted November 23, 2013 Report Share Posted November 23, 2013 You're upside down! Instead of removing everything but commas and counting what's left, simply replace the commas with nothing and count the difference in length between the original and new strings! Quote Link to comment Share on other sites More sharing options...
acantor Posted November 23, 2013 Author Report Share Posted November 23, 2013 Paul and Cory, Very clever! Thank you! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.