简单的正则表达式编程问题
我正在使用 Yahoo Pipes 获取 Twitter feed 并过滤信息。 Pipes 的正则表达式函数是用 ________ 迭代替换 __________。
我的例子是:
Testbedots: happy "twins"
我试图找到一个正则表达式字符串,该字符串将选择除双引号内的内容之外的所有内容。我假设只有一组报价。在正则表达式的替换方面,我看到人们使用 $1,$2,$3 来替换正则表达式函数第一部分中标识为变量的内容。这个想法是将“双胞胎”一词或引号之间的任何内容从行中取出并替换整行。
有什么建议吗?我显然是正则表达式的新手,但已经阅读在线教程几个小时而没有取得任何进展。
谢谢你的帮助,
斯凯勒
I am using Yahoo Pipes to take a twitter feed and filter information out. Pipes' regex function is a replace __________ with ________ iteration.
My example is:
Testbedots: happy "twins"
I am trying to find a regex string that will select everything but what is within the double quotations. I am assuming there will only be one set of quotations. In the replace side of regex, I have seen people use $1,$2,$3 to replace with something identified as a variable in the first part of the regex function. The idea is to pull the word twins, or whatever is between quotes out of the line and have it replace the whole line.
Any recommendations? I am obviously new at regex's but have been reading the online tutorials for hours without making any headway.
Thank you for your help,
Skyler
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
在 Yahoo Pipes 中,您可以使用此表达式将整行替换为引用的文本:
并将其替换为
对于您的示例,它将替换 Testbedots: happy "twins" 为 twins >。
我假设文本中总是恰好有两个引号 (")。
另请注意,您的问题有点令人困惑。您说您想要一个表达式",它将选择除什么之外的所有内容在双引号内”。听起来您想要整行,但不是引用的文本。
In Yahoo Pipes you can use this expression to replace the whole line with the quoted text:
and replace it with
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.
尝试这个正则表达式
这将“在‘:’字符之前获取一个单词,并在空格之前获取最大的字符序列,后跟双引号”
Try this regular expression
This will "get a word before ':' character and the biggest character sequence before a space followed by double quotation mark"
不确定 Pipes 的语法,但通常使用与 perl 兼容的正则表达式语法,我认为你可以这样做
Not sure on the syntax of Pipes, but generally with perl-compatible regex syntax I think you could do something like
我可能会将正则表达式写为:
换句话说,从双引号开始匹配,匹配非双引号字符,直到到达另一个双引号。括号表示您感兴趣的内容。如果您想要至少一个字符(空字符串不起作用),请输入 + 而不是 *****。
这会将您感兴趣的位放入 $1 或第一个捕获的匹配的任何特定语法中。
I'd probably write the regular expression as:
In other words, start matching at a double quote, match non-double-quote characters until you get to another double quote. The parentheses indicate what you're interested in. If you want at least one character (an empty string doesn't work) put a + instead of a *****.
This would put the bit you're interested in into $1 or whatever your particular syntax is for the first captured match.