Helpful
    Preparing search index...

    Function peelBetween

    • Peels the values between an opening string set and a closing string set.

      The actual value will handle issues with internal opening and closing brackets

      Parameters

      • str: string

        The string to peel between.

      • open: string

        The opening string. This will test at the start of str.

      • close: string

        The closing string. This can be anywhere in the str. If this is equal to open, then the open string is removed from the start of the string and the rest of the string would be returned.

      Returns [string | null, string]

      A tuple where the first argument is string that was found between the opening and closing bracket. Returns null if no string could be found between an open and close pair. The second argument will be the remaining text of the string, including whitespace.

      const [peeled, rest] = peelBetween('[a, b, [c1, c2],[d]] other', '[' ']');

      // Outputs 'a, b, [c1, c2], [d]'
      console.log(peeled);

      // Outputs ' other' - white space is included'
      console.log(rest);