String Manipulation- Remove

Hello guys,

Looking for some advice here since I’m encounter some problem.

I have a dynamic string example of text:

  1. Tickets No : PCP-20210707-12345 created with No: QR20210707-56789 created successfully.
  2. Tickets No : PCP-20210707-9080012 created successfully. Need to create manually.

So I’m trying to capture PCP-20210707-9080012 or PCP-20210707-12345.

I use Substring to remove the first part because it has the same number of character. But couldn’t figure out on how to remove the part after the text I want to capture.

Get that value into a string variable (consider strTicketNo)and then you can use below logic:
strTicketNo.remove("Tickets No : “).split(” "c)(0)

Do I need to assign it to string variable?

I got an error “Options Strict On disallows implicit conversion from String to Integer”

Hi @jenkim, You can also refer below steps:
1 -Create test variable of string type and assign value to it.
2 - test.Substring(test.LastIndexOf(":") + 2 ,test.Length - test.LastIndexOf(":") - 2)

Input - Tickets No : PCP-20210707-12345
Output - PCP-20210707-12345

I would use regex for that:
http://regexstorm.net/tester?p=PCP-\d{8}-\d%2B&i=Tickets+No+%3A+PCP-20210707-12345+created+with+No%3A+QR20210707-56789+created+successfully. Tickets+No+%3A+PCP-20210707-9080012+created+successfully.+Need+to+create+manually.

2 Likes

I tried your solution but it will get the wrong ticket number.

Output: QR20210707-56789 created successfully.

By this do you mean I need to use Matches activity and use for each loop to get the string?

1 Like

@jenkim - please check this…

Assign it to a string variable…

Or If you want use Regex…

image

 system.text.regularexpressions.regex.Match("YourString","(?<=Tickets No : )\S+").value

Assign above statement to string variable.

1 Like

How about below statement using assign activity
YourString.Split(":“c)(1).Split(” "c)(0)

1 Like

Thank you all for your solution. Really appreciate it. :grinning:

1 Like

Yes… Get that value into string variable.

Many Thanks.

Regards,
Shubham Agrawal

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