Eclipse Regex搜索行首和行尾不起作用 [英] Eclipse Regex Search for beginning and end of line not working
问题描述
这是一个小问题,但已经困扰了我一段时间.当我在Eclipse中执行查找或查找/替换时,我使用 ^
或 $
并检查正则表达式框中,我总是收到一条消息:
This is a small question, but it has been nagging me for a while. When I do a Find or Find/Replace in Eclipse and I use ^
or $
and check the Regular Expressions box, I always get a message:
找不到字符串
我不明白为什么.我知道 CTRL + SPACE
内容辅助功能,即使我从列表中选择 ^
,它也不起作用.
I don't understand why. I know about the CTRL+SPACE
content assist feature and even when I select ^
from the list, it does not work.
I was looking at this question, Regex to match start of line and end of line for quick find and replace, but it is not working for me. Other regex searches like ^.
or ;$
work fine.
I see that ^
and $
are anchor characters, and do not match a string per se, but these characters seem to work in other editors.
例如,我想将数据列表转换为SQL in子句.
For example, I want to convert a list of data into an SQL in clause.
发件人:
1
2
3
Hi
I need to quote these!
收件人:
'1',
'2',
'3',
'Hi',
'I need to quote these!',
如您所说,
推荐答案
^
和 $
是零宽度的定位符,因此它们在任何情况下都不会匹配他们自己.您需要在锚点上使用某些内容,以匹配文件中的所有内容.
^
and $
are zero-width anchors as you said, therefore they will not match anything by themselves. You need to use something with the anchors in order to match anything in your file.
这篇关于Eclipse Regex搜索行首和行尾不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!