How to Contains Help

Hi,

i want to use Contains Sometimes there will be special characters.

example

“SubjectLCM-S”
“Subject:LCM-S”

My Flow not working

Hi @punnipah

Try with this expression

if(System.Text.RegularExpressions.Regex.Replace(Currentitem.Subject.Tostring,"\W","").Contains("SubjectLCMS"),"S")

Regards
Gokul

1 Like

maybe the Code retrieval can better be setup with a regex:
grafik

strPattern = "(?<=Subject:?LCM-)\w+\b"
strCode = System.Text.RegularExpressions.Regex.Match(strTextVar, strPattern).Value

with an evaluation of the retrurned string also the default case code can be handled

[CheatSheet] - System.Text.RegularExpressions | RegEx - News / Tutorials - UiPath Community Forum

1 Like

Hi,

In this case, it might be better to use Strings.Right and String.IndexOf or regex instead of String.Contains, as the following.

Strings.Right(CurrentItem.Subject,CurrentItem.Subjet.Length-CurrentItem.Subject.IndexOf("-")-1)

OR

System.Text.RegularExpressions.Regex.Match(CurrentItem.Subject,"(?<=-).*").Value

These return characters after “-”

Regards,

1 Like

Thank you very much

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