此正则表达式(RegEx)标志是什么意思/iD [英] What Does This Regular Expression (RegEx) Flag Mean /iD

查看:129
本文介绍了此正则表达式(RegEx)标志是什么意思/iD的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用此正则表达式来验证IPv6,但我想了解它所做的一切 https://stackoverflow.com/a/1934546/3112803

I'd like to use this regular expression for validating IPv6 but I want to understand everything it does https://stackoverflow.com/a/1934546/3112803

^(?>(?>([a-f0-9]{1,4})(?>:(?1)){7}|(?!(?:.*[a-f0-9](?>:|$)){8,})((?1)(?>:(?1)){0,6})?::(?2)?)|(?>(?>(?1)(?>:(?1)){5}:|(?!(?:.*[a-f0-9]:){6,})(?3)?::(?>((?1)(?>:(?1)){0,4}):)?)?(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])(?>\.(?4)){3}))$/iD

,但是我不知道该标志的末尾是什么:/iD.我知道/i标志意味着忽略大小写,但是我找不到任何地方的D功能.我以为这个答案已经有效了很多,但是这篇文章说没有D标志: https://stackoverflow.com/a/4415233/3112803

but I don't know what this flag at the end does: /iD. I know the /i flag means ignore case but I can't find what D does anywhere. That answer has been upvoted a lot some I'm assuming its valid, but this post says there is no D flag: https://stackoverflow.com/a/4415233/3112803

我正在尝试在PL/SQL中使用它,并且未正确验证任何有效的字符串:

I'm trying to use this in PL/SQL and it's not validing any valid string correctly:

if ( REGEXP_LIKE(v,'/^(?>(?>([a-f0-9]{1,4})(?>:(?1)){7}|(?!(?:.*[a-f0-9](?>:|$)){8,})((?1)(?>:(?1)){0,6})?::(?2)?)|(?>(?>(?1)(?>:(?1)){5}:|(?!(?:.*[a-f0-9]:){6,})(?3)?::(?>((?1)(?>:(?1)){0,4}):)?)?(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])(?>\.(?4)){3}))$/iD') ) then

推荐答案

这是Regex PCRE风格的标志.请参阅PHP.net手册页上的注释:

It's a flag in the PCRE flavour of Regex. See the note on the PHP.net manual page:

http://php.net/manual/en/reference. pcre.pattern.modifiers.php (在代码示例下)

D(PCRE_DOLLAR_ENDONLY)- 如果设置了此修饰符,则模式中的美元元字符仅在以下位置匹配 主题字符串的末尾.如果没有此修饰符,则一美元也可以匹配 如果是换行符,则紧接在最后一个字符之前 (但不能在其他任何换行符之前).该修饰符被忽略 如果设置了m修饰符.在Perl中没有与此修饰符等效的东西.

D (PCRE_DOLLAR_ENDONLY) - If this modifier is set, a dollar metacharacter in the pattern matches only at the end of the subject string. Without this modifier, a dollar also matches immediately before the final character if it is a newline (but not before any other newlines). This modifier is ignored if m modifier is set. There is no equivalent to this modifier in Perl.

这篇关于此正则表达式(RegEx)标志是什么意思/iD的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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