Removing Trailing Spaces in a variable

Hi all, I have used GET TEXT to import a name into a variable. The name looks something like this

joe h. bloggs I have use LEFT/RIGHT to try to get the last part of the name (bloggs) as a new variable, however I keep getting a blank result

i.e
Full Text = Test (Contains the Name) - I have checked its populated using message box
Seperator = " "

I think there is a blank space at the end of the name so when trying to get a LEFT result I end up with nothing

How do I trim the end of the text

PLEASE NOTE this is studioX and not studio

Any help would be appreciated

Hi

Try this in assign or a previous step.
“YOURVARIABLE.trim.tostring”

You could also try using Regex to grab the last word and then trim that also:

See this link for a preview

Thanks for the reply, StudioX doesnt have an assign (studio does) where would I put this?

You should be able to use the “trim” function in the output/result field of the get text.

Remember you can use “ctrl + space” to see that syntax options you have available. Look for “trim” then “tostring”

I have this

Saved.Values(Of System.String)(“Test”). you cant add trim to this, im confused

Hi again

Can you try this solution:

But use this Regex pattern:
\w+(?=\s*$)

Regex.Match(Saved.Values(Of String)(“StrInput”),” \w+(?=\s*$)").Value

Hi thanks, I have seen that previously, however regex is not a menu option in studioX

Hold on, I may have been too quick with that reply, apologies

So added a write line activity plus the code you gave me thank you, i get this

REGEX is not declared error message

Please try this…

system.text.regularexpressions.Regex.Match(Saved.Values(Of String)("StrInput"),” \w+(?=\s*$)").Value

that got rid of the error thank you

Where does the result get recorded?

You can use “Save for Later activity” and save the output to another variable.

HI, thanks for the reply, the Write Line activity does not have a save for later option, or am i missing something?

sorry not awake yet, understand what you mean

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