删除Microsoft Excel中特定标记之间的文本 [英] Remove text between specific tags in Microsoft Excel

查看:131
本文介绍了删除Microsoft Excel中特定标记之间的文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些这样的文本:


Lorem ipsum dolor< code> sit amet,consectetuer adipiscing elit, /代码> sed diam nonummy nibh euismod tincidunt ut< code> laoreet dolore magna< / code> aliquam erat volutpat。


我正在尝试删除每对代码标签之间的所有内容。当每个单元格只有一对标签时,我写了一个功能很好的功能,但它并不适用于多个实例。以下是所需的输出:


Lorem ipsum dolor< code>< / code> sed diam nonummy nibh euismod tincidunt ut< code>< / code>你要建议我做什么?

解决方案

基于宏记录器:

  Sub Test()
'working for选择替换所有< *> section
Selection.Replace What:=&* *>,Replacement:=,LookAt:= xlPart,_
SearchOrder:= xlByRows,MatchCase:= False,SearchFormat:= False, _
ReplaceFormat:= False
End Sub

编辑尝试2,在OP的评论之后:

  Sub Attempt_second()
'用于选择替换所有< * GT; section
Selection.Replace what:=< * code> *< * / * code>,替换:=< code>< / code>,LookAt:= xlPart,_
SearchOrder:= xlByRows,MatchCase:= False,SearchFormat:= False,_
ReplaceFormat:= False
End Sub

它会将文本替换为< code>< / code> 删除其间的其他空格。


I have some text that goes like this:

Lorem ipsum dolor <code>sit amet, consectetuer adipiscing elit,</code> sed diam nonummy nibh euismod tincidunt ut <code>laoreet dolore magna</code> aliquam erat volutpat.

I am trying to remove everything between each pair of "code" tags. I wrote a function that works well when there is only one pair of tags per cell, but it doesn't take care of multiple instances. Here is the desired output:

Lorem ipsum dolor <code></code> sed diam nonummy nibh euismod tincidunt ut <code></code> aliquam erat volutpat.

How would you advise me to do?

解决方案

Based on macro recorder:

Sub Test()
    'working for selection replacing all <*> sections
    Selection.Replace What:="<*>", Replacement:="", LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
End Sub

Edit attempt 2, after comments from OP:

Sub Attempt_second()
    'working for selection replacing all <*> sections
    Selection.Replace What:="<*code>*<*/*code>", Replacement:="<code></code>", LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
End Sub

It will replace text into <code></code> removing additional spaces in between.

这篇关于删除Microsoft Excel中特定标记之间的文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆