How to remove the first 3 words in a string

Hey there guys i screen scraped a string and the only way i was able to split the string was to replace the keywords i was looking for with special characters plus the keyword, so one of the keywords is “Profile” and i replaced it with “*| Profile” and then i get the value that comes after. This method works for all of the other keywords but I get an exception for Profile because, I think it is because there are words that comes before it and the name is always going to be different. I feel it works for the others because there isn’t word before them. So the string looks like below: How do I remove everything before the “*|”. Thank you in advance!

Contact Info
Susy’s *| Profile
myprofile
*| Email
myemail.com
*| Hired
Jan 4, 2023

@olmccb

Can you tell us what is the required output …that way we can procide better details…I see the same symbol in 3 places …which whole string you want to remove?

Can you show 2 sample inputs and expected output

This removes till the last

System.Text.RegularExpressions.Regex.Replace(str,"[\s\S]*(?=\*\|)","",RegexOptions.Multiline)

If needed only till profile

System.Text.RegularExpressions.Regex.Replace(str,"[\s\S]*(?=\*\| Profile)","",RegexOptions.Multiline)

Cheers

1 Like

hi @Anil_G , my goal is get the value, so in the case of Susy’s *| Profile i get ‘myprofile’ and for *|Email i get the value which ‘myemail.com’ and for *| Hired i get the value also which is the date. The words "Contact Info’ will always be there and the name will always be there also but it will be different. So i want to get rid of for “Contact Info” and the name. Hope that helps! Thank you very much!

@olmccb

Please check my above response …I edited it to include what you needed

Please try and let me know if it works

Cheers

hi there i used an assign activity and i changed the type to Regex but i get an exception:
Cannot assign from type “System.String” to type “System.Text.RegularExpressions.Regex” in assign activity
image

@olmccb

The output of this will be a string only…dont chnage to regex or anything… str is the input string and newstring should be of type string again

Cheers

that worked thank you!!

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