如何删除里面的字符串“ < div dir =" ltr"> test mail 1 body< br>< / div>"? [英] How to remove string from which is inside " <div dir="ltr">test mail 1 body<br></div>"?
本文介绍了如何删除里面的字符串“ < div dir =" ltr"> test mail 1 body< br>< / div>"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Hello All,
我有一个字符串
Hello All,
I have a string
<div dir="ltr">Test Mail 1 Body<br></div>
现在我只想删除
and now i want to remove only
<div dir="ltr">
输出应为
Output should be
Test Mail 1 Body
无法删除,有人可以帮帮我吗?
我尝试过的事情:
Unable to remove, can anybody please help me?
What I have tried:
string str = body.Replace("<div dir="ltr>"", " ");
我收到当前上下文中不存在ltr名称的错误。
I am getting error that ltr name does not exist in current context.
推荐答案
string inputText = "<div dir=\"ltr\">Test Mail 1 Body<br></div>";
string pattern = "<div dir=\"ltr\">(.*)</div>";
Regex regex = new Regex(pattern);
var matches = regex.Match(inputText);
string text = matches.Groups[1].ToString();
text = text.Replace("<br>", "");
这篇关于如何删除里面的字符串“ < div dir =" ltr"> test mail 1 body< br>< / div>"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文