1

我正在使用 Yahoo Pipes 获取 Twitter 提要并过滤信息。Pipes 的正则表达式函数是用 ________ 迭代替换 __________。

我的例子是:

Testbedots: happy "twins"

我正在尝试找到一个正则表达式字符串,它将选择除双引号内的所有内容之外的所有内容。我假设只有一组报价。在正则表达式的替换方面,我看到人们使用 $1,$2,$3 来替换正则表达式函数第一部分中标识为变量的东西。我们的想法是将单词 twins 或引号之间的任何内容从行中提取出来,并让它替换整行。

有什么建议吗?我显然是 regex 的新手,但已经阅读了几个小时的在线教程而没有取得任何进展。

谢谢您的帮助,

斯凯勒

4

4 回答 4

1

In Yahoo Pipes you can use this expression to replace the whole line with the quoted text:

^.*"(.*)".*$

and replace it with

$1

For your example, it would replace Testbedots: happy "twins" with twins.

I assume there are always exactly two quotes (") in the text.

Also note, that your question is a bit confusing. You said you want an expression "that will select everything but what is within the double quotations". That sounds like you want the whole line but not the quoted text.

于 2009-10-08T07:42:14.320 回答
0

试试这个正则表达式

(\w+:.*?) "

这将“在 ':' 字符之前获取一个单词,并且在空格后跟双引号之前获取最大字符序列”

于 2009-10-08T02:28:17.167 回答
0

不确定管道的语法,但通常与 perl 兼容的正则表达式语法我认为你可以做类似的事情

s/[^"]*"([^"]+)"[^"]*/$1/
于 2009-10-08T02:33:24.643 回答
0

我可能会将正则表达式写为:

/"([^"]*)"/

换句话说,从双引号开始匹配,匹配非双引号字符,直到找到另一个双引号。括号表示您感兴趣的内容。如果您想要至少一个字符(空字符串不起作用),请使用+而不是 *****。

这会将您感兴趣的位放入 $1 或您的第一个捕获匹配的特定语法中。

于 2009-10-08T02:36:48.500 回答