:relfileprefix: ../../../ [#boost-urls-grammar-optional_rule] == xref:boost.adoc[pass:[boost]]::xref:boost/urls.adoc[pass:[urls]]::xref:boost/urls/grammar.adoc[pass:[grammar]]::optional_rule Match a rule, or the empty string === Synopsis Declared in header `` [source,cpp,subs="verbatim,macros,-callouts"] ---- template constexpr pass:q[_implementation-defined_] optional_rule(Rule const& r); ---- === Description Optional BNF elements are denoted with square brackets. If the specified rule returns any error it is treated as if the rule did not match. [,cpp] ---- using value_type = optional< typename Rule::value_type >; ---- === Rules are used with the function xref:boost/urls/grammar/parse-02.adoc[grammar::parse] . [,cpp] ---- system::result< optional< core::string_view > > rv = parse( "", optional_rule( token_rule( alpha_chars ) ) ); ---- [,cpp] ---- optional = [ rule ] ---- * link:https://datatracker.ietf.org/doc/html/rfc5234#section-3.8[3.8. Optional Sequence (rfc5234)] === Parameters |=== | Name | Description | *r* | The rule to match |=== === See Also xref:boost/urls/grammar/alpha_chars.adoc[alpha_chars] , xref:boost/urls/grammar/parse-02.adoc[parse] , xref:boost/urls/optional.adoc[optional] , xref:boost/urls/grammar/token_rule.adoc[token_rule] .