Split Text

Hi Guys,

Need your help on following split text, I would like split the text before word contains “Address” example:
“Gokul Vasan Address Chennai” - I want to extract “Gokul Vasan” only

“Shankar Address Chennai” - I want to extract “Shankar” only

“James Anton Prince Address Delhi” - I want to extract “James Anton Prince” only.

Can any one help me out on this.

Thank you,
Gokul.

Hey @gokulvasant,

Assuming str is the string contains “Shankar Address Chennai”

You can use str.Split({“Address”},System.StringSplitOptions.None)(0)
This will get you whatever comes before “Address” just like you need it :slight_smile:

Regards.

3 Likes

I would use a regex for that.

System.Text.RegularExpressions.Regex.Match(variablestring, "^.*?(?= Address)").ToString()

This will get everything from the start of a string until " Address" is found.
An advantage of this solution is that it wont find matches that do not contain " Address".

1 Like

Hi @gokulvasant,

Try using substring of the text available in the textbox like the following,

strAddress.Substring(0, strAddress.IndexOf(“Address”))

This will give you the text before “Address” from the entire text.

1 Like

Thank you all…

It’s working like a charm. Once again thank you guyz…

1 Like

Hi Guyz,

One more thing I have sequence of rows like follows:
Paid Paid by Company
Paid $1000 CTD $5,000.25 remaining $2,000.00 Amount
Paid Same Paid by Consumer
Paid $250 CTD $4,250.25 remaining $3,500.00 Amount

I this I want to split into 3 columns or variables only if I get payment / amount details i.e., 2 and 4 fourth row only. If I get only content means I want to leave as it is.
I want to leave this row “Paid Paid by Company” as it is
then I want to split to this “Paid $1000 CTD $5,000.25 remaining $2,000.00 Amount”
like “$1000” “$5,000.25” and 2,000.00

Am trying to use Split string activity but it throwing error like : Assign : Index was outside the bounds of the array. in some times.

Please let me know how to achieve the same.

Thank you,
Gokul.

Once again you can use Regex to pick out the specific numbers. Either that or the substring + index of that Sarathi125 suggested

Hi - Use the following regex’s to extract Amounts-
With Decimal Amounts(like $5,000.25, $2,000.00) - “[$][\d,]+[\s,.]\d{2}”
Without decimal - “[$]\d{3}”

Thanks,
Nitesh