10-24-2018 02:25 PM
Hello, I have a string as shown below, I need to count the \s between the comma. I found an example that counts the total of \s of the string, as shown. Can you help me?
Solved! Go to Solution.
10-24-2018 02:36 PM
Split string at first comma. Find 2nd comma and split it there.
Now do the search for spaces on the part in between.
10-24-2018 04:36 PM
Are you sure that's really how the string comes out? I suspect you're looking for literal strings of \s when you should be looking for a space.
10-25-2018 06:44 AM - edited 10-25-2018 06:46 AM
If instead of counting between the commas I turn into an array and perform the count?
10-25-2018 07:52 AM - edited 10-25-2018 08:14 AM
I still am doubtful that those \s are literally what you are looking for. Or is that string indicator in backslash display mode? If it is, this is a great time to learn that if you have controls, indicators, and/or constants that aren't displaying in their default fashion, it's pretty mandatory that you show this on your object by showing the radix on a numeric or the display mode on a string to avoid this kind of confusion.
Edit: I am leaving this post up even after figuring out what display mode the control is in so you can learn a bit about coding for other devs. (Just beause you know what display mode the control is in doesn't mean anyone else does.)
10-25-2018 07:58 AM
What I need is to count the number of characters, and I also need to know what character is and what is space (\s). I can get the string convert to array and do these counts in the array, no problem.
10-25-2018 07:59 AM - edited 10-25-2018 08:07 AM
Oh well, now I that I've decoded the picture - I'm much better at decoding actual code - I see that the string control is actually in backslash mode, given the search string. So Raven has beaten me by a day. 😉
But I'm wondering why you have to do this. What is it going to help you to do? Maybe there's a better way to do whatever it is you're trying to accomplish?
10-25-2018 08:10 AM
BTW - Search and Replace with "all" returns the number of replacements made, so you can use that in a loop and just add up all the results.
10-25-2018 10:56 AM - edited 10-25-2018 10:59 AM
Pretty flexible solution, if you know reg.ex.'s.
, must match exact character (comma)
([^,]*) Matches 0-n characters that are not a comma, and return in first capturing group
, must match exact character (comma)
10-25-2018 01:37 PM
Below is what I did. I changed the spaces by * and then converted to array. How could I now, from this array, count the characters of each value?