Does Ruby support conditional regular expressions(Ruby 是否支持条件正则表达式)
问题描述
只是一个语言功能问题,我知道在正则表达式(或多个正则表达式)之外有很多方法可以做到这一点.
Just a language feature question, I know there's plenty of ways to do this outside of regexes (or with multiple regexes).
ruby 是否支持 条件正则表达式?基本上,正则表达式中的 IF-THEN-ELSE 分支,其中 IF 的谓词是表达式中捕获的组的存在(或不存在).
Does ruby support conditional regular expressions? Basically, an IF-THEN-ELSE branch inside a regular expression, where the predicate for the IF is the presence (or absense) of a captured group in the expression.
在 perl 中,语法是 (?(predicate)yes-pattern|no-pattern)
和
In perl, the syntax is (?(predicate)yes-pattern|no-pattern)
as in
/(?:y|(x))(?(1)y|x)/
我无法在我浏览过的任何 ruby 文档中找到任何类似内容的参考,但我想我会在这里询问以确保,以防我搜索错误的单词,或者它已从文档中删除.
I haven't been able to find any reference to anything like it in any ruby docs that I've browsed, but I figured I'd ask here to make sure, in case I was searching for the wrong words, or it was elided from the docs.
推荐答案
不,ruby 不支持(1.8 和 1.9 都不支持).
No, ruby does not support that (neither in 1.8 nor 1.9).
这篇关于Ruby 是否支持条件正则表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Ruby 是否支持条件正则表达式


- 检查具有纬度和经度的地理点是否在 shapefile 中 2022-01-01
- 使用公司代理使Python3.x Slack(松弛客户端) 2022-01-01
- CTR 中的 AES 如何用于 Python 和 PyCrypto? 2022-01-01
- 使用 Cython 将 Python 链接到共享库 2022-01-01
- 计算测试数量的Python单元测试 2022-01-01
- 我如何卸载 PyTorch? 2022-01-01
- ";find_element_by_name(';name';)";和&QOOT;FIND_ELEMENT(BY NAME,';NAME';)";之间有什么区别? 2022-01-01
- 如何使用PYSPARK从Spark获得批次行 2022-01-01
- YouTube API v3 返回截断的观看记录 2022-01-01
- 我如何透明地重定向一个Python导入? 2022-01-01