How to remove specific dynamic string

Hi all .

I’m new here. i got a problem whenever i want to get text from this string . I only want the name word instead the salutation use at the front. The things is, the selector get text only allowed me to get the whole name and salutation . and the salutation keep on changing. If im using Remove(,).toString i can only remove certain Salutation that has length that already set to remove. Kindly help me to give solution for this.

Eg,

MR TEST ABC
MADAM TEST DEF
DR IR TEST GHIJKLM

** MR, MADAM DR IR , is few example the salutation that i need to remove. How can to get the Name at the back only

Hey @user123mem

You can use Regex.Replace to remove the first word - which should be the salutation. Preview Pattern #1 here. Or you can try pattern #2 which is more fixed on the each Salutation being entered.

Do you have more samples we can test?

Try this using an Assign:

Left Assign
Clean_String

Right Assign
System.Text.RegularExpressions.Regex.Replace(INSERTRAWVARIABLE, “^(MR|MADAM|DR)”, “”)

Learn Regex with my MegaPost :slight_smile:

Cheers

Steve

HI Steve,

What kind of sample that you want ?

i try using your suggestion here "System.Text.RegularExpressions.Regex.Replace(INSERTRAWVARIABLE, “^(MR|MADAM|DR)”, “”)

" and assign it to variable , my the message box still display name with Salutation.

Here my workflow

image

this is screenshot of the message box
image

still returning the original

Hey @user123mem

You need to update the highlighted variable with “strCustNm”
image

Like this - try inserting the below:
System.Text.RegularExpressions.Regex.Replace(strCustNm, “^(MR|MADAM|DR)”, “”)

If you are still having trouble, please copy the text you have in here:
image

Let me know how you go :slight_smile:

Cheers

Steve

yaa i already update the variable to strCustNm but the salutation is still there.

Hi Steve,

your solution is working. Actually i forgot to include with ": " here since it comes with the salutation there. so i just update it like here System.Text.RegularExpressions.Regex.Replace(strCustNm, “^(: MR|: MADAM|: DR)”, “”)

and the salutation is remove.

image

Thank you for your time ! appreciate it !

1 Like

Hey @user123mem

Oh nice! Glad I could help.

I just started to build you a workflow. Sounds like the sample wasn’t 100% accurate :sweat_smile:

Glad you have a resolution.

Remember to add all the known salutations you can find :slight_smile:
Just as an FYI, the pipe (“|”) means or, so you can add as many salutations as you want :blush:

Cheers

Steve

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