View source code
Display the source code in std/uni.d from which this page was generated on
github.
Improve this page
Quickly fork, edit online, and submit a pull request for this page.
Requires a signed-in GitHub account. This works well for small changes.
If you'd like to make larger changes you may want to consider using
local clone.
Page wiki
View or edit the community-maintained wiki page associated with this page.
Function std.uni.MatcherConcept.skip
Perform a semantic equivalent 2 operations:
decoding a at front of
and testing if
it belongs to the set of of this matcher. inp
The effect on
depends on the kind of function called:inp
Match. If the codepoint is found in the set then range
is advanced by its size in Code unit, code units,
otherwise the range is not modifed.inp
Skip. The range is always advanced by the size
of the tested regardless of the result of test
.
Test. The range is left unaffected regardless
of the result of test
.
Prototype
bool skip(Range)( Range inp ) if (isRandomAccessRange!Range && is(ElementType!Range : char));
Example
string truth = "2² = 4"; auto m = utfMatcher!char(unicode.Number); assert(m.match(truth)); // '2' is a number all right assert(truth == "² = 4"); // skips on match assert(m.match(truth)); // so is the superscript '2' assert(!m.match(truth)); // space is not a number assert(truth == " = 4"); // unaffected on no match assert(!m.skip(truth)); // same test ... assert(truth == "= 4"); // but skips a codepoint regardless assert(!m.test(truth)); // '=' is not a number assert(truth == "= 4"); // test never affects argument
Example
auto m = utfMatcher!char(unicode.Number); string square = "2²"; // about sub-matchers assert(!m.subMatcher!(2,3,4).test(square)); // ASCII no covered assert(m.subMatcher!1.match(square)); // ASCII-only, works assert(!m.subMatcher!1.test(square)); // unicode '²' assert(m.subMatcher!(2,3,4).match(square)); // assert(square == ""); wstring wsquare = "2²"; auto m16 = utfMatcher!wchar(unicode.Number); // may keep ref, but the orignal (m16) must be kept alive auto bmp = m16.subMatcher!1; assert(bmp.match(wsquare)); // Okay, in basic multilingual plan assert(bmp.match(wsquare)); // And '²' too }
Authors
Dmitry Olshansky