Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用regexp仅获取双引号中的内容?_Regex_Shell - Fatal编程技术网

如何使用regexp仅获取双引号中的内容?

如何使用regexp仅获取双引号中的内容?,regex,shell,Regex,Shell,如果没有此字符串的双引号,如何获取url: <p>The document has moved <a href="http://xxx/aaa/index.html">here</a>.</p> 文档已移动 假设html字符串位于名为“regexp.html”的文件中,您可以使用regex模式http:[^”]+ $ruby-n-e'm=$\.match(/(http[^“]+)/);如果m'

如果没有此字符串的双引号,如何获取url:

<p>The document has moved <a href="http://xxx/aaa/index.html">here</a>.</p>
文档已移动


假设html字符串位于名为“regexp.html”的文件中,您可以使用regex模式
http:[^”]+

$ruby-n-e'm=$\.match(/(http[^“]+)/);如果m'

这仅在url以“http”开头时有效。

awk'NR==6{print;exit}'a.html | grep[\“].[\“]。我用awk只是为了接我想要的那行我用了grep/http:[^“]+/我得到了提示。这不起作用。你能解释一下吗?@好奇-学习如何使用grep:
grep--h
thanx我不知道--h是解决方案。你的评论真的很有用
$ ruby -n -e 'm = $_.match(/(http[^"]+)/); puts m if m' < regexp.html 
http://xxx/aaa/index.html