Skip to main content

Hello, I have a variable in my workflow whose length is not consistent. I want to run an action in the workflow to remove the last two characters (always the last 2). I believe regular expression is the way to do this, but I do not know how to format the action. Thanks!

Hi @AutomationPerso 

  1. Count the string length → int_textlength
  2. Calc int_textlength_minus2 = int_textlength - 2
  3. Use the Modify String action to Extract substring  

 Export Key: PCHLvfgoVViDnC5FnkcnwFNrnpha9cjULXS8zYXYnoWqRXs5L


Interesting. Why does “count collection” count the number of characters? Shouldn’t it return a value of 1 since there is only one value in the collection?

Also, I think a simpler way to do this (thanks to your help) would be apply a regex and split using the expression .{2}$


Interesting. Why does “count collection” count the number of characters? Shouldn’t it return a value of 1 since there is only one value in the collection?

It extract each character and insert into a collection. “apple” → p“a”, “p”, “p”, “l”, “e”]
Once the length is known, its easy to extract from a string eg 1st three chars, last three chars etc

 

Also, I think a simpler way to do this (thanks to your help) would be apply a regex and split using the expression .{2}$

With regex, there is many ways to manipulate strings. 

 


Reply