[英]Extract string from a String in c#
我怎么能得到这个:
Mu6AQUVX/YWxpYmFkOTE5KycrMzJAZ21haWwuY29t/?app_redirect=False"
从链接:
https://facebook.com/accounts/confirm_email/Mu6AQUVX/YWxpYmFkOTE5KycrMzJAZ21haWwuY29t/?app_redirect=False"
提取此字符串:
#039;ll see their posts in your feed.</p></td></tr><tr style=""><td height="30" style="line-height:30px;" colspan="1"> </td></tr><tr><td style=""><a href="https://facebook.com/accounts/confirm_email/Mu6AQUVX/YWxpYmFkOTE5KycrMzJAZ21haWwuY29t/?app_redirect=False" style="color:#3b5998;text-decoration:none;display:block;width:370px;"><table border="0" width="100%" cellspacing="0" cellpadding="0" style="border-collapse:collapse;"><tr>
您可以使用下面的函数来获取两个单词之间的字符串:
public static String GetTextBetween(String source, String leftWord, String rightWord)
{
return
Regex.Match(source, String.Format(@"{0}\s(?<words>[\w\s]+)\s{1}", leftWord, rightWord),
RegexOptions.IgnoreCase).Groups["words"].Value;
}
使用您的参数调用以下函数:
GetTextBetween("your full text to search from", "start fix text", "end fix text")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.