From a468213917b793c47d98e172b2f0a3853460c367 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Wed, 11 Jan 2023 21:56:42 +0900 Subject: [DOC] Mention the conditional regexp --- doc/regexp.rdoc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/doc/regexp.rdoc b/doc/regexp.rdoc index 92c7ecf66e..c6c983d1d9 100644 --- a/doc/regexp.rdoc +++ b/doc/regexp.rdoc @@ -405,6 +405,15 @@ a single one that matches any of the expressions. Each expression is an /\w(and|or)\w/.match("furandi") #=> # /\w(and|or)\w/.match("dissemblance") #=> nil +== Condition + +The (?(cond)yes|no) +syntax matches _yes_ part if _cond_ is captured, otherwise matches _no_ part. +In the case _no_ part is empty, also | can be omitted. + +The _cond_ may be a backreference number or a captured name. A backreference +number is an absolute position, but can not be a relative position. + == Character Properties The \p{} construct matches characters with the named property, -- cgit v1.2.3