【发布时间】:2019-05-15 15:01:34
【问题描述】:
通常,您会使用以下表达式从字符串中删除所有子字符串:
text.Replace(" uipath_custom_id=""587""","")
这会删除字符串中的所有子字符串,并且在没有任何此类子字符串时不会抛出异常。
但是如果引号之间有未知字符怎么办?有未知字符时如何达到相同的结果?
这是我要处理的字符串。有时它包含多个“uipath_custom_id=""587""" 子字符串,有时没有。
outerhtml='<div class="_3_7SH _3DFk6 message-out" uipath_custom_id="567"><div class="Tkt2p"><div class="copyable-text" data-pre-plain-text="[9:42 AM, 5/15/2019] sash: "><div class="_3zb-j ZhF0n"><span dir="ltr" class="selectable-text invisible-space copyable-text">Hello World!</span></div></div><div class="_2f-RV"><div class="_1DZAH" role="button"><span class="_3EFt_">9:42 AM</span><div class="_32uRw"><span data-icon="msg-time" class=""><svg id="Layer_1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 15" width="16" height="15"><path fill="#859479" d="M9.75 7.713H8.244V5.359a.5.5 0 0 0-.5-.5H7.65a.5.5 0 0 0-.5.5v2.947a.5.5 0 0 0 .5.5h.094l.003-.001.003.002h2a.5.5 0 0 0 .5-.5v-.094a.5.5 0 0 0-.5-.5zm0-5.263h-3.5c-1.82 0-3.3 1.48-3.3 3.3v3.5c0 1.82 1.48 3.3 3.3 3.3h3.5c1.82 0 3.3-1.48 3.3-3.3v-3.5c0-1.82-1.48-3.3-3.3-3.3zm2 6.8a2 2 0 0 1-2 2h-3.5a2 2 0 0 1-2-2v-3.5a2 2 0 0 1 2-2h3.5a2 2 0 0 1 2 2v3.5z"></path></svg></span></div></div></div></div><span></span></div>'
【问题讨论】:
-
定义“未知字符”,它们是什么以及为什么会出现?
标签: string vb.net replace character