This is the latest docs version
Quick Links
  • -Overview
  • -Language Features
  • -JS Interop
  • -Build System
Documentation
Language Manual
Reference for all language features
ReScript & React
First class bindings for ReactJS
GenType
Seamless TypeScript integration
Reanalyze
Dead Code & Termination analysis
Exploration
Packages
Explore third party libraries and bindings
Syntax Lookup
Discover all syntax constructs
APIPlaygroundBlogCommunity
  • Playground
  • Blog
  • Twitter
  • GitHub
  • Forum
Core Module
Overview
Core
submodules
  • Array
  • ArrayBuffer
  • AsyncIterator
  • BigInt
  • BigInt64Array
    • Constants
    BigUint64Array
    • Constants
  • Console
  • DataView
  • Date
    • UTC
  • Dict
  • Error
    • URIError
    • TypeError
    • SyntaxError
    • ReferenceError
    • RangeError
    • EvalError
  • Exn
  • Float
    • Constants
    Float32Array
    • Constants
    Float64Array
    • Constants
    Int
    • Constants
    Int16Array
    • Constants
    Int32Array
    • Constants
    Int8Array
    • Constants
  • Internal
  • Intl
    • Segments
    • Segmenter
    • RelativeTimeFormat
    • PluralRules
    • NumberFormat
      • Grouping
    • Locale
    • ListFormat
    • DateTimeFormat
    • Collator
    • Common
  • Iterator
  • JSON
    • Decode
    • Encode
    • Classify
  • List
  • Map
  • MapperRt
  • Math
    • Int
    • Constants
  • Null
  • Nullable
  • Object
  • Option
  • Ordering
  • Promise
  • Re
    • Result
      • t
        t
      • v
        fullMatch
      • v
        matches
      • v
        index
      • v
        input
    RegExp
    • Result
  • Result
  • Set
  • String
  • Symbol
  • Type
    • Classify
  • TypedArray
  • Uint16Array
    • Constants
    Uint32Array
    • Constants
    Uint8Array
    • Constants
    Uint8ClampedArray
    • Constants
  • WeakMap
  • WeakSet
  • API / Core / Re / Result

    Result

    t

    RESCRIPT
    type t = array<string>

    Type representing the result of a RegExp execution.

    fullMatch

    RESCRIPT
    let fullMatch: t => string

    fullMatch(regExpResult) returns the full string that matched in this result.

    Examples

    RESCRIPT
    // Match the first two words separated by a space let regexp = RegExp.fromString("(\\w+) (\\w+)") switch regexp->RegExp.exec("ReScript is pretty cool, right?") { | None => Console.log("Nope, no match...") | Some(result) => Console.log(result->RegExp.Result.fullMatch) // Prints the full string that matched, "ReScript is" }

    matches

    RESCRIPT
    let matches: t => array<string>

    matches(regExpResult) returns all matches for regExpResult.

    Examples

    RESCRIPT
    // Match the first two words separated by a space let regexp = RegExp.fromString("(\\w+) (\\w+)") // This below will log "ReScript" and "is" to the console. switch regexp->RegExp.exec("ReScript is pretty cool, right?") { | None => Console.log("Nope, no match...") | Some(result) => switch result->RegExp.Result.matches { | [firstWord, secondWord] => Console.log2(firstWord, secondWord) | _ => Console.log("Didn't find exactly two words...") } }

    index

    RESCRIPT
    let index: t => int

    input

    RESCRIPT
    let input: t => string

    input(regExpResult) returns the full input string that was passed to what produced the RegExp.Result.t.

    Examples

    RESCRIPT
    // Match the first two words separated by a space let regexp = RegExp.fromString("(\\w+) (\\w+)") // This below will log the full input string "ReScript is pretty cool, right?" to the console. switch regexp->RegExp.exec("ReScript is pretty cool, right?") { | None => Console.log("Nope, no match...") | Some(result) => Console.log(result->RegExp.Result.input) }
    Types and values
    • t
      t
    • v
      fullMatch
    • v
      matches
    • v
      index
    • v
      input

    © 2024 The ReScript Project

    Software and assets distribution powered by KeyCDN.

    About
    • Community
    • ReScript Association
    Find us on