[#boost-urls-url_view_base-fragment] = xref:boost.adoc[boost]::xref:boost/urls.adoc[urls]::xref:boost/urls/url_view_base.adoc[url_view_base]::fragment :relfileprefix: ../../../ :mrdocs: Return the fragment == Synopsis Declared in `<https://www.github.com/boostorg/url/blob/develop/include/boost/url/url_view_base.hpp#L2111[boost/url/url_view_base.hpp]>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template<xref:boost/urls/string_token.adoc[string_token]::xref:boost/urls/string_token/StringToken.adoc[StringToken] StringToken = xref:boost/urls/string_token.adoc[string_token]::xref:boost/urls/string_token/return_string.adoc[return_string]> StringToken::result_type fragment(StringToken&& token = {}); ---- == Description This function calculates the fragment of the url, with percent escapes decoded and without the leading pound sign ('#') whose presence indicates that the url contains a fragment. This function accepts an optional _StringToken_ parameter which controls the return type and behavior of the function: * When called with no arguments, the return type of the function is `std::string` . Otherwise * When called with a string token, the behavior and return type of the function depends on the type of string token being passed. === Example [,cpp] ---- assert( url_view( "http://www.example.com/index.htm#a%2D1" ).fragment() == "a-1" ); ---- === Complexity Linear in `this‐>fragment().size()`. === Exception Safety Calls to allocate may throw. String tokens may throw exceptions. === BNF [,cpp] ---- fragment = *( pchar / "/" / "?" ) fragment-part = [ "#" fragment ] ---- === Specification * link:https://datatracker.ietf.org/doc/html/rfc3986#section-3.5[3.5. Fragment (rfc3986)] Return the fragment This function calculates the fragment of the url, with percent escapes decoded and without the leading pound sign ('#') whose presence indicates that the url contains a fragment. This function accepts an optional _StringToken_ parameter which controls the return type and behavior of the function: * When called with no arguments, the return type of the function is `std::string` . Otherwise * When called with a string token, the behavior and return type of the function depends on the type of string token being passed. === Example [,cpp] ---- assert( url_view( "http://www.example.com/index.htm#a%2D1" ).fragment() == "a-1" ); ---- === Complexity Linear in `this‐>fragment().size()`. === Exception Safety Calls to allocate may throw. String tokens may throw exceptions. === BNF [,cpp] ---- fragment = *( pchar / "/" / "?" ) fragment-part = [ "#" fragment ] ---- === Specification * link:https://datatracker.ietf.org/doc/html/rfc3986#section-3.5[3.5. Fragment (rfc3986)] == Parameters |=== | Name | Description | *token* | An optional string token to use. If this parameter is omitted, the function returns a new `std::string`. | *token* | An optional string token to use. If this parameter is omitted, the function returns a new `std::string`. |=== == See Also xref:boost/urls/url_view_base/encoded_fragment.adoc[encoded_fragment], xref:boost/urls/url_view_base/has_fragment.adoc[has_fragment]. xref:boost/urls/url_view_base/encoded_fragment.adoc[encoded_fragment], xref:boost/urls/url_view_base/has_fragment.adoc[has_fragment]. [.small]#Created with https://www.mrdocs.com[MrDocs]#