public final class RegexObject extends AbstractConstantKeysObject
RegexObject represents a compiled regular expression that can be used to match against
input strings. It is the result of executing a RegexEngine. It exposes the following
three properties:
String pattern: the source of the compiled regular expressionTruffleObject flags: the set of flags passed to the regular expression
compiler. The type differs based on the flavor of regular expressions used:
RegexFlags if the flavor was ECMAScriptPythonFlags if the flavor was PythonStr or PythonBytesint groupCount: number of capture groups present in the regular expression, including
group 0.RegexObject.RegexObjectExecMethod exec: an executable method that matches the compiled
regular expression against a string. The method accepts two parameters:
Object input: the character sequence to search in. This may either be a
String or a TruffleObject that responds to
InteropLibrary.hasArrayElements(Object) and returns Characters on indexed
InteropLibrary.readArrayElement(Object, long) requests.Number fromIndex: the position to start searching from. This argument will be
cast to int, since a String can not be longer than Integer.MAX_VALUE. If
fromIndex is greater than Integer.MAX_VALUE, this method will immediately return
NO_MATCH.RegexResult. The contents of the exec can be compiled
lazily and so its first invocation might involve a longer delay as the regular expression is
compiled on the fly.
| Modifier and Type | Class and Description |
|---|---|
static class |
RegexObject.RegexObjectExecMethod |
AbstractConstantKeysObject.IsReadableCacheNode, AbstractConstantKeysObject.ReadCacheNode| Constructor and Description |
|---|
RegexObject(RegexCompiler compiler,
RegexSource source,
com.oracle.truffle.api.interop.TruffleObject flags,
int numberOfCaptureGroups,
Map<String,Integer> namedCaptureGroups) |
| Modifier and Type | Method and Description |
|---|---|
Object |
getCompiledRegexObject() |
RegexObject.RegexObjectExecMethod |
getExecMethod() |
com.oracle.truffle.api.interop.TruffleObject |
getFlags() |
TruffleReadOnlyKeysArray |
getKeys() |
com.oracle.truffle.api.interop.TruffleObject |
getNamedCaptureGroups() |
int |
getNumberOfCaptureGroups() |
RegexSource |
getSource() |
Object |
readMemberImpl(String symbol) |
void |
setCompiledRegexObject(com.oracle.truffle.api.interop.TruffleObject compiledRegexObject) |
getMembers, hasMembers, isMemberReadable, readMembergetLanguage, hasLanguage, toDisplayStringpublic RegexObject(RegexCompiler compiler, RegexSource source, com.oracle.truffle.api.interop.TruffleObject flags, int numberOfCaptureGroups, Map<String,Integer> namedCaptureGroups)
public RegexSource getSource()
public com.oracle.truffle.api.interop.TruffleObject getFlags()
public int getNumberOfCaptureGroups()
public com.oracle.truffle.api.interop.TruffleObject getNamedCaptureGroups()
public Object getCompiledRegexObject()
public void setCompiledRegexObject(com.oracle.truffle.api.interop.TruffleObject compiledRegexObject)
public RegexObject.RegexObjectExecMethod getExecMethod()
public TruffleReadOnlyKeysArray getKeys()
getKeys in class AbstractConstantKeysObjectpublic Object readMemberImpl(String symbol) throws com.oracle.truffle.api.interop.UnknownIdentifierException
readMemberImpl in class AbstractConstantKeysObjectcom.oracle.truffle.api.interop.UnknownIdentifierException