Removing unwanted text outside <>

前端 未结 2 1055
忘了有多久
忘了有多久 2021-01-29 06:48

I want to remove all text except the text within <>\'s from a textbox.

2条回答
  •  遇见更好的自我
    2021-01-29 07:14

    This is off the top of my head, but hopefully will steer you in the right direction :)

    String email = "www.abc.com ";
    String result = "";
    
    int firstIndex = email.IndexOf('<'); 
    int lastIndex = email.IndexOf('>');
    if(lastIndex > firstIndex)
        result = email.Substring(firstIndex + 1, lastIndex-firstIndex-1);
    

提交回复
热议问题