How to identify consecutive numbers in uipath

Hi,

I have an Quote id which contains digits “123456789” now my bot needs to identify whether the numbers are consecutive or repetitive

Can anyone help me i will truly appreciate their efforts

Thanks in advance

1 Like
  1. Use a For Each activity to loop through each character in the quote ID.
  2. Inside the loop, use an Assign activity to assign the current character to a variable (let’s call it currentDigit).
  3. Use an If activity to check if the next character in the quote ID is equal to the current character. You can use the IndexOf activity to find the index of the current character and then use the Substring activity to get the next character.
  4. If the next character is equal to the current character, set a boolean variable (let’s call it isRepetitive) to True.
  5. If the next character is not equal to the current character, set a boolean variable (let’s call it isConsecutive) to True.
  6. After the For Each loop, use a Decision activity to check the values of isRepetitive and isConsecutive and display the appropriate message using a Message Box or Write Line activity.

Can you define what you mean by “consecutive” and “repetitive”, and give examples of input with desired output?

That’s not the same thing. That Regex just matches if there are 3 or more digits next to each other. This post here is asking about if the numbers are in order.

Google is always a good place to start. Here is a comprehensive discussion and code examples for this kind of logic.

Hi @rsr.chandu

To determine if the numbers in the Quote ID are consecutive, you can use the following logic:

a. Convert the Quote ID to an array of characters: Use the quoteId.ToCharArray() method to convert the quoteId variable into an array of characters.

b. Iterate over the array: Use a For Each activity to iterate over each character in the array.

c. Check for consecutive digits: Within the loop, compare each digit with the next digit to check if they are consecutive. You can use the Ascii code of the characters to perform the comparison.

Thanks!