between

Summary

Matches all substrings between two delimiters.

Usage

public string[] between(string openingDelimiter, string endingDelimiter)

Returns

An array with all matched substrings between the occurrences of the specified delimiters.

Parameters

openingDelimiter

The delimiter that marks the beginning of a substring match. The delimiter will not be matched.

endingDelimiter

The delimiter that marks the end of a substring match. The delimiter will not be matched.

Description

Gets all the substring matches between the two specified delimiter substrings.

Internally, the match marker starts from the matching opening delimiter (if applicable). The ending delimiter is matched from the position of the opening delimiter. This process repeats until all matches are found. Delimiters are not included in the returned matches.

Examples

Basic Usage
1
2
3
4
import System;
 
string foo = "foobarbaz";
Console.log(foo.between("foo", "baz")); // [ "bar" ]
Get all substrings between quotation marks
1
2
3
4
5
import System;
 
string quotedWords = '"duck" "swan" "crab"';
string[] words = quotedWords.between('"', '"');
Console.log(words); // [ "duck", "swan", "crab" ]

Share

HTML | BBCode | Direct Link