How to split value in single quotes after specific string

hello,

i have below kind of errors

Cannot add user. ‘ABC’ does not exist, user is already a member of ‘Test_abc’ group
Cannot add user. ‘PQR’ does not exist

i only need value ABC and PQR from whole string.
“Cannot add user.” this is constant for each error.
help me on same to get only those values

@Mathkar_kunal Share dummy string value, if possible and expected output!

i have entioned

same like below one by on e error i am getting in loop

error 1] Cannot add user. ‘ABC’ does not exist, user is already a member of ‘Test_abc’ group
error 2] Cannot add user. ‘PQR’ does not exist

expected output

1] ABC
2] PQR

Hi @Mathkar_kunal

Try this

(?<=Cannot\s*add\s*user\.\s*‘)(\w+)

Or

(?<=Cannot\s*add\s*user.*)([A-Z]+)

System.Text.RegularExpressions.Regex.Match(Input,"(?<=Cannot\s*add\s*user.*)([A-Z]+)").Value

Regards,

(?<=Cannot add user. ['‘]).*?(?=['’])

we cannot rely on inverted single quotes like ‘ as it could be a copy paste issue but can handle defensive it

Okay @Mathkar_kunal

You are iterating through each string and you are getting error like: User does not exist.

Just create a empty list above your loop

myList = New List(Of String())

and put a try catch in for each activity in try block put all your activities, and in catch block use Append Item to Collection Activity.

At the end you will get all the Users which will throw an error!

Best regards,
Ajay Mishra

tried not working for Cannot add user. ‘ABC’ does not exist, user is already a member of ‘Test_abc’ group (giving output as T)this but worked for Cannot add user. ‘PQR’ does not exist

error 1] and error 2] i have added for understanding please dont consider that and it is not likke each user contains only 3 letters like abc it may differ like abcd or fdsfss

unfortunately feedback is not clear. please rephrase and let us know in detail

  • what was done
  • what is failling
  • used sample data
    Thanks

i have below kind of errors in loop one by one (errors are copied from webpage using extract data table)

Cannot add user. ‘ABC’ does not exist, user is already a member of ‘Test_abc’ group
Cannot add user. ‘PQRJYF’ does not exist
Cannot add user. ‘PQRD’ does not exist

need output like below
ABC
PQRJYF
PQRD

Pattern from above looks good:

also have a look here:
[CheatSheet] - System.Text.RegularExpressions | RegEx - News / Tutorials - UiPath Community Forum

[HowTo] LINQ (VB.Net) Learning Catalogue - Help / Something Else - UiPath Community Forum


i am using same expression then why output is like this

because you are using a toString / Message Box and it will not return the variable content but the datatype for this case. It is not a bug, it is the right behaviour from .Net.

inspections are done via debugging and e.g. debugging panels:
Understanding the 6 Debugging Panels of UiPath in the easiest way possible! - News / Tutorials - UiPath Community Forum

along e.g. with this statemtent:
String.Join(",", Result.Cast(Of Match).Select(Function (x) x.Value))

ok my bad one mistake from my end

Cannot add user ‘abc’, user is already a member of ‘Test_Sanjeer’ (“.” is not there after user in such errors when it contains extra line as “already member of”

give me revised expression

its better to tell us all the samples and variations on the begin. Also, share text samples (SOP) always with us

(?<=Cannot add user\.? ['‘]).*?(?=['’])

yes,
thanks worked now

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