Explorer

core.string-index-of

description
The byte index of the first target in the text at or after start (-1 if none). core.eval-value runs it compiled (core.eval-native-part)
type
Fn(text: String, target: String, start: Number) -> Number
expression
fn(text$0, target$1, start$2) =>
  let end$3 = @core.plus(left: $2, right: @core.string-length(value: $1));
  match @core.less-than(left: @core.string-length(value: $0), right: $3) {
    true =>
      @core.minus(left: 0, right: 1),
    false =>
      match @core.equal(left: @core.string-slice(value: $0, start: $2, end: $3), right: $1) {
        true =>
          $2,
        false =>
          @core.string-index-of(text: $0, target: $1, start: @core.plus(left: $2, right: 1))
      }
  }
visibility
public
core.string-index-of (project definy, branch localized-descriptions, snapshot 4UAxOcclWZD2NPiuAIppcpCjShSw41vxBIT6qrjlNLc)
id: w094tRBTyBNOZveCCAr7pWE00XAZK__JXyTjHWIgSTo
content hash: JaO35tyeZyAdEVRJbYZ-lYPIYD-Ld3X83JZoKF-seog