如何在Visual Studio 2012查找和替换对话框中匹配空格? [英] How do I match space(s) in Visual Studio 2012 Find and Replace dialog?

查看:115
本文介绍了如何在Visual Studio 2012查找和替换对话框中匹配空格?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





尽我所能,我找不到与Visual Studio 2012查找和替换对话框中的一个或多个空格匹配的表达式。我想尝试匹配以下表达式:



Hi,

Try as I might, I cannot find an expression to match one or more spaces in the Visual Studio 2012 Find and Replace dialog. I am trying to match expressions like the following:

<p class="StyleA">Chapter 12</p>





表达式完全不变,除了两件事:



1.有'Chapter'和它后面的数字之间可能不止一个空格。

2.显然章节号会改变,使用任何数字字符序列[0-9]。



我的最新尝试如下,但两者只匹配章节一词的结尾。





The expression is completely constant except for two things:

1. There may be more than a single space between 'Chapter' and the number that follows it.
2. Obviously the chapter number changes, using any sequence of numeric characters [0-9].

My latest attempts are as follows, but both match only as far as the end of the word 'Chapter'.

<p class="StyleA">Chapter[^<]+</p>




<p class="StyleA">Chapter[ ]+</p>





任何人都可以看到我错在哪里好吗?





亲切的愿望~Patrick



Can anyone see where I am going wrong, please?


Kind wishes ~ Patrick

推荐答案

问题是你只匹配 p -tags包含后跟一些水疗中心ces,没有号码。请改为尝试:

The problem is that you only match p-tags containing Chapter followed by some spaces, without the number. Try this instead:
<p class="StyleA">Chapter +\d+</p>



此外,它不是将空间放入角色类所必需的。



如果您不仅要匹配空格,而是所有空格,请用 \\替换空格\\ s


Also, it's not necessary to put the space into a character class.

If you don't only want to match spaces, but all whitespace, then replace the space with \s

<p class="StyleA">Chapter\s+\d+</p>


这篇关于如何在Visual Studio 2012查找和替换对话框中匹配空格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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