Community

Replace everything after certain character Answered

Hi all,

I have an email address "shelon1986"<shelon0619@xyz.com>. How to remove""shelon1986" and get only "shelon0501@xyz.com" as output.

 

Was this article helpful?

0 out of 0 found this helpful

Comments

4 comments

  • Avatar
    Vladimir Dimitrijević

    Hi Sara,

    Here is some C# example you can use to retrieve only values between "<" and ">":

                string st = "\"shelon1986\"<shelon0619@xyz.com>";
                int from = st.IndexOf("<") + 1;
                int to = st.LastIndexOf(">");
                st = st.Substring(from, to - from);

    It will work if you create warning script rule on your field and add these lines of code. Instead of "st" use: Context.Field("ReplaceWithYourFieldName").Text;

    Best regards,
    Vladimir

    1
  • Avatar
    Vladimir Dimitrijević

    Hi, 

    Just to add code you will use in script rule, to make it easier for you:

                string st = Context.Field("ReplaceWithYourFieldName").Text;
                int from = st.IndexOf("<") + 1;
                int to = st.LastIndexOf(">");
                Context.Field("ReplaceWithYourFieldName").Text = st.Substring(from, to - from);

    Best regards,
    Vladimir

    1
  • Avatar
    Sara

    Thank you Mr. Vladimir..! I did as you said and It works fine. Thank you very much

    1
  • Avatar
    Vladimir Dimitrijević

    Hi Sara, 

    You're most welcome! I'm glad I helped.

    Best regards,
    Vladimir

    0

Please sign in to leave a comment.