MS Word 中的正则表达式获取找到的单词之前的单词?

发布于 2024-07-21 07:42:23 字数 663 浏览 3 评论 0原文

基本上我正在使用 MS Word 的查找和替换功能(通配符:true),

但我必须编辑的文本包含混乱搜索的内容:

//more text in different format above

<file name="london_bitmap" bits="24", owner="sergio"> 1 2 3 </file>
<file name="paris_bitmap" bits="24", owner="sergio"> 1 2 3 </file>
<file name="moscow_bitmap" bits="24", owner="sergio"> 1 2 3 </file>

我想用 bmp 前缀替换位图,所以:

<file name="bmp_london" bits="24", owner="sergio"> 1 2 3 </file>

当我使用这样的东西时:

(<*>)_(<bitmap>)

它捕获不是 1 行,而是它能找到的所有行,直到它到达“位图”

关于如何解决这个问题的想法吗? 也许但是在“位图”之前得到这个词?

Basically I am using MS Word's find and replace feature (wildcard:true)

but the text I have to edit contains stuff that messes up the search:

//more text in different format above

<file name="london_bitmap" bits="24", owner="sergio"> 1 2 3 </file>
<file name="paris_bitmap" bits="24", owner="sergio"> 1 2 3 </file>
<file name="moscow_bitmap" bits="24", owner="sergio"> 1 2 3 </file>

I want to replace bitmap with a bmp prefix so:

<file name="bmp_london" bits="24", owner="sergio"> 1 2 3 </file>

When I use something like this:

(<*>)_(<bitmap>)

it captures not 1 line but all it can find till it hits "bitmap"

Any idea on how to solve this? Maybe but getting the word just previous to "bitmap"?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

落墨 2024-07-28 07:42:23

以下内容(在 Word 2003 中)作为搜索字符串

([!"]@)_(<bitmap>)

[!"] 部分的含义是:匹配不是双引号字符的任何单个字符,@ 限定符表示“查找至少一个前面的“。替换表达式(我希望您已经知道:)是

bmp_\1

希望这会有所帮助!

The following works (in Word 2003) as the search string

([!"]@)_(<bitmap>)

The [!"] part means : match any single character that isn't a double quote character, and the @ qualifier means "find at least one of the preceding". The replacement expression (which I expect you already know :) is

bmp_\1

Hope this helps!

笑梦风尘 2024-07-28 07:42:23

不确定 word 是否支持惰性求值,但您可以尝试用 * 替换 * ?

Not sure if word supports lazy evaluation but you might try replacing * by *?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文