正则表达式问题
我需要一些帮助来解决我遇到的一些正则表达式问题。首先,双引号 "
。
""
之间的任何内容都需要匹配。下一个问题我需要匹配以 '
开头的任何内容,直到行尾 \n
或
没有任何想法可以匹配。
我已经尝试了各种方法,但似乎 意识到我需要将引号放在 "
和 "
之间。
I need some help with some regular expression problems I am having. First off, double quotes "
.
Anything between ""
needs to be matched. Next problem I need to match anything that starts with a '
till the end of a line \n
or <br />
.
I've tried all sorts, but nothing seems to match it. Any ideas?
Sorry guys, just realised I need the quotes to be between "
and "
.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
简单化:
将匹配双引号之间的任何内容,尽管它不适用于转义双引号,例如
对于 EOL 的单引号,您可以使用
更新:Sylverdrag's made a valid point;匹配您需要的引号
,然后获取匹配的第一个子组。我看到问题已经更新,提到应该使用
"
- 我的答案可以很容易地适应这一点。Simplistic:
will match anything between double quotes, though it won't work with escaped double quotes such as
For the single-quote to EOL, you can use
Update: Sylverdrag's made a valid point; to match between the quotes you'd need
and then get the first subgroup of the match. I see the question's been updated to mention that
"
should be used - my answer can be adapted to this easily enough.尝试:
双引号:
单引号直到行尾或
:Try:
Double quotes:
Single quote till end of line or
<br/>
:引号之间的任何内容
从 ' 到行尾的
anything between quotes
from ' till end of line
尝试这些正则表达式:
Try these regular expressions:
为了变得更时髦一点,只匹配双引号内的内容,而不匹配引号本身:
To get a bit more funky and match only what is inside the double quotes but not the quotes themselves: