Stage 4 Draft / January 19, 2018

s/dotAll flag for regular expressions

The algorithm listed in 21.2.3.2.2 is modified as follows.

1Runtime Semantics: RegExpInitialize ( obj, pattern, flags )

When the abstract operation RegExpInitialize with arguments obj, pattern, and flags is called, the following steps are taken:

  1. If pattern is undefined, let P be the empty String.
  2. Else, let P be ? ToString(pattern).
  3. If flags is undefined, let F be the empty String.
  4. Else, let F be ? ToString(flags).
  5. If F contains any code unit other than "g", "i", "m", "s", "u", or "y" or if it contains the same code unit more than once, throw a SyntaxError exception.
  6. If F contains "u", let BMP be false; else let BMP be true.
  7. If BMP is true, then
    1. Parse P using the grammars in 21.2.1 and interpreting each of its 16-bit elements as a Unicode BMP code point. UTF-16 decoding is not applied to the elements. The goal symbol for the parse is Pattern[~U]. Throw a SyntaxError exception if P did not conform to the grammar, if any elements of P were not matched by the parse, or if any Early Error conditions exist.
    2. Let patternCharacters be a List whose elements are the code unit elements of P.
  8. Else,
    1. Parse P using the grammars in 21.2.1 and interpreting P as UTF-16 encoded Unicode code points (6.1.4). The goal symbol for the parse is Pattern[+U]. Throw a SyntaxError exception if P did not conform to the grammar, if any elements of P were not matched by the parse, or if any Early Error conditions exist.
    2. Let patternCharacters be a List whose elements are the code points resulting from applying UTF-16 decoding to P's sequence of elements.
  9. Set obj.[[OriginalSource]] to P.
  10. Set obj.[[OriginalFlags]] to F.
  11. Set obj.[[RegExpMatcher]] to the internal procedure that evaluates the above parse of P by applying the semantics provided in 21.2.2 using patternCharacters as the pattern's List of SourceCharacter values and F as the flag parameters.
  12. Perform ? Set(obj, "lastIndex", 0, true).
  13. Return obj.

The section 21.2.2.1 Notation is modified as follows.

2Notation

The descriptions below use the following variables:


The algorithm listed in 21.2.2.8 Atom is modified as follows.

3Atom

The production Atom::. evaluates as follows:

  1. Let A be the set of all characters except LineTerminator.
  2. If DotAll is true, then
    1. Let A be the set of all characters.
  3. Otherwise, let A be the set of all characters except LineTerminator.
  4. Call CharacterSetMatcher(A, false) and return its Matcher result.

The algorithm listed in 21.2.5.3 is modified as follows.

4get RegExp.prototype.flags

RegExp.prototype.flags is an accessor property whose set accessor function is undefined. Its get accessor function performs the following steps:

  1. Let R be the this value.
  2. If Type(R) is not Object, throw a TypeError exception.
  3. Let result be the empty String.
  4. Let global be ToBoolean(? Get(R, "global")).
  5. If global is true, append "g" as the last code unit of result.
  6. Let ignoreCase be ToBoolean(? Get(R, "ignoreCase")).
  7. If ignoreCase is true, append "i" as the last code unit of result.
  8. Let multiline be ToBoolean(? Get(R, "multiline")).
  9. If multiline is true, append "m" as the last code unit of result.
  10. Let dotAll be ToBoolean(? Get(R, "dotAll")).
  11. If dotAll is true, append "s" as the last code unit of result.
  12. Let unicode be ToBoolean(? Get(R, "unicode")).
  13. If unicode is true, append "u" as the last code unit of result.
  14. Let sticky be ToBoolean(? Get(R, "sticky")).
  15. If sticky is true, append "y" as the last code unit of result.
  16. Return result.

The following new section is added before 21.2.5.10 get RegExp.prototype.source.

5get RegExp.prototype.dotAll

RegExp.prototype.dotAll is an accessor property whose set accessor function is undefined. Its get accessor function performs the following steps:

  1. Let R be the this value.
  2. If Type(R) is not Object, throw a TypeError exception.
  3. If R does not have an [[OriginalFlags]] internal slot, then
    1. If SameValue(R, %RegExpPrototype%) is true, return undefined.
    2. Otherwise, throw a TypeError exception.
  4. Let flags be R.[[OriginalFlags]].
  5. If flags contains the code unit "s", return true.
  6. Return false.