Substring?

I want to obtain the text aligned on the right from a particular charracter.
The text written on the left from the charracter has a variable number of charracters
For example: 123456 / text or 123456789/ text ( both string)
Now I only want the “text” from charracter “/“ on
How can I solve this

@Marcelino

I’m trying to get better at RegEx functions so if anyone here can improve my suggestion, please do!

I would use a RegEx expression to find the text. You can also use substring. This expression should work based on your requirements above

\ /(.*)

Hi @Marcelino,

the output which you required will be “text” as it is after /, right?

If yes, then you can do substring from the index you found that certain character

@Marcelino
You can try to split the string with “/” as delimiter and get the string at the index 1.

Attached the xaml for reference. Main.xaml (5.2 KB)

Hi,
Split(stringVariable,"/") this will give you array of string having values before / and after /.

use accordingly

Does this help you,
Regards,
Pavan H

Like @bradsterling mentioned, you can use substring method or regex match to find your string. Both have their uses.

In general, substring method is easier to read/understand but is much less powerful. See below link for information. Based on the limited info we have, this would likely be fastest/easiest to code. You’d simply do the following in 1 assign activity. I’ll assume OutputText is the text you want to pull out and is a string variable. InputText is the string you want to pull text from and is a string variable.

Assign OutputText = InputText.Substring(String.LastIndexOf("/")+1).Trim

If you prefer to use Regex, make sure you are using VB.NET syntax. I use this website for a quickreference guide as well as to test out my pattern: http://regexstorm.net/tester

The code written by @bradsterlingis very close to working, but will also bring in any whitespace characters, and also includes the “/” itself in the match. Here is a regex pattern that searches for the forward slash and a whitespace character, then matches any non-whitespace characters that come after it. If you want to include ALL characters on that line (including whitespace) simply switch the \w* with a .* instead
(?<=/ )\w*

1 Like

Hi @Marcelino
I’ll suggest you to use Split as given below

Text = str.Split({"/"}, StringSplitOptions.None)(1)

here, str is your string variable containing whole string and text is string variable where you’ll get desire text.

1 Like

Thanks for your help:
I solved, however regex more reliable, the next option worked for me:
For example I’ ve 12345678/Date
If I only want to get “Date” I used ToString.Split(MyVariable, “ /”c)(1)
If you want the whole number you use ToString.Split(MyVariable, “ /”c)(0)
so (1) = for text on the right and (0) for text on the left.
I’ve to work out how regex works and practice before I use it.

Greetings

1 Like