String operations counting number of variables in a string

Hi everyone,

I have a string which contains the following info in this format.
ResellerName/ResellerEmail/UserName/UserEmail or just UserName/UserEmail without reseller.

For example, the data can come in adam/ adam@abc.com/ bryan/ bryan@cbd.com or just in the format bryan/ bryan@cbd.com

My strategy is to count the number of ' / ' in the string and do a split operation according to the number of ' / ' and values in the list into an array.

However it seems there are no operations that let me count number of ' / ' in a string. Anyone able to help me on this?

Comments

  • edited May 2019

    Try this approach. Attached task bot also.

    Happy Automation!

  • edited May 2019

    There are many ways to achieve the same result and here at Extra Technology we have listed a range of suitable examples below. The initial method is similar to the response from Ranjith and all will work equally as well. The atmx file is zipped up below.

  • Hi @Ranjith , woudn't both give the same output since you need to initialize the list variable with 4 values at first?

  • njwnjw
    edited May 2019

    Anyway, i got this answer from somewhere else and figured i would share it here:

    you can use string Length command to get numbers of this character

    then use String Repalce to remove "/" with empty character and get length of this

    then use vraiable operation to get number of this character

    note ::: this is solution if you input is Variable like : "a/s//f/g/g/g/b/c/t/gv/g/g"![]

    (https://automationanywhereanswers.com/uploads/editor/nr/ihbd5f89v7va.png "")

    1.png 8.1K
  • edited August 2019

    thanks

  • Use a regex replace String operation in conjunction with String length.
    1. Replace any character that is not a / with nothing.
    2. Get length of resulting String

    Here is an ATMX exported as text:
    1 String Operation: Replace "[^/]" with "" in "Jeremy/Gordon/Flowers" and assign output to $Prompt-Assignment$
    2 String Operation: Get length of "$Prompt-Assignment$" and assign output to $Prompt-Assignment$
    3 Message Box: "$Prompt-Assignment$"

  • edited December 2019
    1. Use a regex replace String operation in conjunction with String length. Be sure the regex is ticked. (The code says replace any character that is NOT a / with an empty string. The power/hat symbol does the negation).
    2. Get length of resulting String

    Here is an ATMX exported as text:
    1 String Operation: Replace "[^/]" with "" in "Jeremy/Gordon/Flowers" and assign output to $Prompt-Assignment$
    2 String Operation: Get length of "$Prompt-Assignment$" and assign output to $Prompt-Assignment$
    3 Message Box: "$Prompt-Assignment$"

Sign In or Register to comment.