Skip to main content

between_strings

The between_strings text helper is used to extract text from a haystack located between the start_needle and end_needle

Returns a string which is the subset of haystack between start_needle and end_needle and not including start_needle or end themselves.

If either start_needle or end_needle not present in haystack, returns an empty string.

If either start_needle or end_needle is empty, throws an exception.

Usage

{{between_strings haystack start_needle end_needle flags="irxt"}}

Arguments

haystack
The input string

start_needle
The starting boundary string.

end_needle
The ending boundary string.

flags

  • i: Treat delimiters as not case-sensitive (default is case-sensitive)
  • r: split text at last instance of start and last instance of end (default is to split at the first instance of each)
  • x: expand located text: use the first found instance of start and the last found instance of end
  • t: trim the final result prior to returning (remove all whitespace from beginning and end)

Examples

Within a web form, return the value of the field called "First Name"

{{between_strings custom.web_form "First Name:" "n"}}