Disp selected characters

hi

i have string “Venkat” i need to disp only first 2 characters “Ve”

how to disp pls help me

thank you

Use string function like substring.

sorry
actually i don’t know how to write substring function in uipath
can u pls send me the substring

string str = yourStringVariable.Substring(0,2)

  1. Use Assign Activity.
  2. on the left side hit ctrl+k and give a name str.
  3. Go to down variable pane and change the str variable type to string.
  4. Assign right side ** yourStringVariable.Substring(0,2)**
  5. Write line your str variable.

Regards…!!
Aksh

check this workflowsubstring.xaml (4.9 KB)

tysm!! its working now

thanq

Just in case another person wants an alternative a .left() function will also work.This outputs a specified number of characters starting from the left hand side of the string. There is also .right() which, as you can imagine, goes from the right hand side of the string.

so instead you may want it to be

a=“VenkatP”

b = a.left(2) // outputs as “Ve”

Thanks

2 Likes

@jakelewis18 Hi, it doesn’t work. There are no such functions under string

If you wnat use left method:
“variable” = Left(“variable”, “lenght”)
@sangasangasanga

1 Like

@pllo2ptk
I tried using Assign
text = Left(“hello”, “length”)
Gives me error: Options strict on disallows implicit conversions from ‘string’ to ‘integer’

Check variable type of TEXT -> must be string
Example

text = left(“aaaa”, 2)

1 Like

Hi @pllo2ptk,

I have a scenario like in excel I have a data
Example - TSPRST12378QR-QT

Here I need to remove from right side first R,with including that R I need to remove
I’m facing like it was taking from first R it was removing entire thing

output - TSPRST12378Q
I need output like this,can you suggest me

If the end of the string is always going to be the same length you could do:

text = right(yourvariable, 3) in assign.

There is probably a better way to do this though in case the string increases in length, using split.

Hi @CBlanchard,

No it will change the length & position as well

R-QT will be always at the end?