Class RegexResult

All Implemented Interfaces:
com.oracle.truffle.api.interop.TruffleObject

public final class RegexResult extends AbstractConstantKeysObject
RegexResult is a TruffleObject that represents the result of matching a regular expression against a string. It can be obtained as the result of a RegexObject's exec method and has the following properties:
  1. boolean isMatch: true if a match was found, false otherwise.
  2. TruffleObject getStart(int groupNumber): returns the position where the beginning of the capture group with the given number was found. If the result is no match, the returned value is undefined. Capture group number 0 denotes the boundaries of the entire expression. If no match was found for a particular capture group, the returned value is -1.
  3. TruffleObject end: returns the position where the end of the capture group with the given number was found. If the result is no match, the returned value is undefined. Capture group number 0 denotes the boundaries of the entire expression. If no match was found for a particular capture group, the returned value is -1.
  4. int lastGroup: The index of the last capture group that was matched. -1 if no capture group was matched. This property is only tracked for Python regular expressions. For other flavors of regular expressions, this always has the value -1.
  • Constructor Details

    • RegexResult

      protected RegexResult(com.oracle.truffle.api.strings.TruffleString input, int fromIndex, int regionFrom, int regionTo, int start, int end, int[] result, com.oracle.truffle.api.CallTarget lazyCallTarget)
  • Method Details

    • getNoMatchInstance

      public static RegexResult getNoMatchInstance()
    • getBooleanMatchInstance

      public static RegexResult getBooleanMatchInstance()
    • create

      public static RegexResult create(int start, int end)
    • create

      public static RegexResult create(int[] result)
    • createFromExecutorResult

      public static RegexResult createFromExecutorResult(Object executorResult)
    • createLazy

      public static RegexResult createLazy(com.oracle.truffle.api.strings.TruffleString input, int fromIndex, int regionFrom, int regionTo, int start, int end, com.oracle.truffle.api.CallTarget lazyCallTarget)
    • getInput

      public com.oracle.truffle.api.strings.TruffleString getInput()
    • getFromIndex

      public int getFromIndex()
    • getRegionFrom

      public int getRegionFrom()
    • getRegionTo

      public int getRegionTo()
    • getStart

      public int getStart()
    • getEnd

      public int getEnd()
    • setResult

      public void setResult(int[] result)
    • getStart

      public int getStart(int groupNumber)
    • getEnd

      public int getEnd(int groupNumber)
    • getLastGroup

      public int getLastGroup()
    • getMembers

      public Object getMembers(boolean includeInternal)
      Overrides:
      getMembers in class AbstractConstantKeysObject
    • getKeys

      public TruffleReadOnlyKeysArray getKeys()
      Specified by:
      getKeys in class AbstractConstantKeysObject
    • isMemberReadableImpl

      public boolean isMemberReadableImpl(String symbol)
      Specified by:
      isMemberReadableImpl in class AbstractConstantKeysObject
    • readMemberImpl

      public Object readMemberImpl(String symbol)
      Specified by:
      readMemberImpl in class AbstractConstantKeysObject
    • debugForceEvaluation

      public void debugForceEvaluation()
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • toDisplayString

      public Object toDisplayString(boolean allowSideEffects)
      Overrides:
      toDisplayString in class AbstractRegexObject