StudioX - Text to Left / Right activity question

I’m on StudioX. I’m using an activity called ‘Text to Left/Right’ to separate out a string based on certain criteria. In this activity, one has to specify a separator. The separator of a string could be a space, a hyphen etc. If there is a string without any separator like this ‘PROD120’, ‘PROD001’, how does one separate letters from digits using ‘Text to Left / Right’ activity of StudioX ? I tried using asterisk, it did not work. Has anybody used it at all ?

@Prinal_C - if there is no separator then you can try like this…


In the write Line , click on the plus sign and first add the variable(StrInput) and now click on the advance editor and add the below formula…

Saved.Values(Of String)(“StrInput”).Remove(4,3)

PROD120 = P is at 0th position…so i have removed from 4th to 3 charars…

My output

@prasath17 Thank you. This worked.
I’ve taken a step further in StudioX to try this with set of values in Excel rows. I’ve about 10 rows with values like ‘PROD603’ on each row. I read in For Each Row loop. I use ‘Save for later’. Left side is a variable named ‘left1’… it shows like this Saved.Values(Of ExcelValue)(“left1”) and on the right I have CurrentRow.ByField(“TestCode”)

Write Line I have Saved.Values(Of ExcelValue)(“left1”).Remove(4,3)
It shows an error "Remove is not a member of UiPath.Excel.ExcelValue

What if one has values like “PROD601”, “PRE4933” like this. How do you make it work in both cases ?

Saved.Values(Of ExcelValue)(“left1”).tostring.remove(4,3) - Please try this…

For this case, you have to go with Regex only…i don’t think there is any way to identify the dynamic cases…

@Prinal_C - Here is how you have to use Regex…

Input: PRE4933

Input: PROD120

Hope this helps…

1 Like

@prasath17 Thank you ! What does that ,"" really mean (towards the end) ?

@Prinal_C - Replace any digits(numbers) with Nothing…So PROD123 becomes PROD…PRE4933 becomes PRE

Thanks. One question, why can’t we use Regex.Match ?

@Prinal_C - if we use Regex.Match and use \d+ it will just extract the numbers. Was it your requirement to extract only the non numeric from the given text?? or did i misunderstood your req?

@prasath17 your understanding is correct. Was wondering if we could use Regex.Match and use ([A-Z])+ to extract non numeric. I have not tried it yet

@Prinal_C - Yes…You can try like this…

Write Line: “Regex Match = " + Regex.Match(Saved.Values(Of String)(“StrInput”),”[A-z]+").Value

Output: Regex Match = PROD

A-z - will cover both upper case and lower case…

1 Like

Worked. Thank you !

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.