Explorer

std.string-index-of

description
Find first byte index of target substring in text at or after startIndex, or -1 if not found
type
Fn(text: String, target: String, startIndex: Number) -> Number
expression
fn(text$1, target$2, startIndex$3) =>
  let textLen$4 = @core.string-length(value: $1);
  let targetLen$5 = @core.string-length(value: $2);
  match @core.greater-than(left: @core.plus(left: $3, right: $5), right: $4) {
    true =>
      -1,
    false =>
      match @core.equal(left: @core.string-slice(value: $1, start: $3, end: @core.plus(left: $3, right: $5)), right: $2) {
        true =>
          $3,
        false =>
          @std.string-index-of(text: $1, target: $2, startIndex: @core.plus(left: $3, right: 1))
      }
  }
visibility
public
std.string-index-of (project definy, branch snapshot-terms, snapshot ITPh_tTKphq4xOBcY4nA69GG9L2laow7SAtvVJWLQaQ)
id: BQTzjZLAnHRHOE8_vaIa1xcdu_b2r2nuLcRai2bDao8
content hash: kavCVApxEdal2aTt3f2l5Xv0nf0cFQfYVEEZ6TIwS2o