Can't Substring

Hi everyone, i have a string " my name is : …Vuong Bui …". So i want retrived substring " Vuong Bui “, i use this string.substring(name.IndexOf(”:"),name.indexOf(".")), bui it not working for me. please help me resovle it:
image

He takes the index of the first . he comes accros, so in your case thats both the same, the second index is also not the end but how many characters you want to include
Is the format of the string always the same? my name is: …some name…?
In that case you could do name = name.SubString(name.IndexOf(".")); and then name.Replace(".","");

1 Like

Hi @TanVuong,

I’m sorry to say that the question is not perfectly clear to me. However, if your string is " my name is : …Vuong Bui …", please try with Regex.

Please try like the below -
Regex.Match(YourStringVariable,"(?<=:\s*.+)[a-zA-Z\s*]+").Value

Hope it will help you.

Thanks & Regards,
Apurba

1 Like

substring.xaml (5.3 KB)

split(test,":")(1).Replace("…","").ToString.Trim

Please use this expression…!

1 Like

when i use indexOf("."), it return to -1, i think the delimeter not found by that command.

tks u for help, my english is so bad.

tks u for help.

Are you sure it’s a part of you strings, and not just the dotted line where you have to put your value, have you checked your string you recieve? I guess you get the value from a website or something like that?

1 Like

Hey @TanVuong,

My dear, please don’t say that your English is bad. Your English is good.

You are most welcome.:slightly_smiling_face:

Thanks & regards,
Apurba

1 Like

Please use indexOf("…"), it will return the index properly.

“…” it is a single character. Not three dots.

Thanks!

1 Like

The expression you entered will return only space. Because it finds “:” and “.” of first occurrence.

Follow the below approach to get the name.

strOutput = name.Replace(".","").Substring(name.IndexOf(":"))

will return the name.

Reards,
Karthik Byggari

sorrry, but my full string is " Tôi tên: Nguyễn Văn A…………………………………………Nam , Nữ  \r\n". I use get text activity to get text in PDF file.