正则表达式查找 " 之间的字符" [英] regex find characters between " "

查看:79
本文介绍了正则表达式查找 " 之间的字符"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何匹配 2 个指定字符之间的所有字符,例如 " " ->来自 sdfsf " 12asdf " sdf

How can I match all characters between 2 specified characters, say " " -> from sdfsf " 12asdf " sdf

我只想得到 12asdf.

推荐答案

您可以使用以下模式获取 " " 之间的所有内容,包括开头和结尾的空格:

You can use the following pattern to get everything between " ", including the leading and trailing white spaces:

"(.*?)"

"([^"]*)"

如果您想捕获 " " 之间的所有内容,但不包括前导和尾随空格,您可以执行以下操作:

If you want to capture everything between the " " excluding the leading and trailing white spaces you can do:

"\s*(.*?)\s*"

"\s*([^"]*)\s*"

这篇关于正则表达式查找 " 之间的字符"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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