outside ... (string function)

Prev Next

Function Names

outside, outside exclude, outside until, outside until exclude

Description

This function extracts a outside parts of the string either with two character position numbers or matching patterns or a combination of both. It is the opposite part of the middle ... function family where the middle part is removed the string and the left and right parts of the strings put together.

Call as: function

Restrictions

Indirect parameter passing is disabled

Parameter count

3

Parameters

No.TypeDescription
1
input
valid types input string or value

Attention: If 1st parameter is a parameter set, please refer to outside [parameter set function] instead.
Values of types other than string will be converted to strings first.

2
input
numeral starting character position

Positive: First part of the string ends before the specified character position (0 = blank, 1 = ends after 1st character, etc.)
Larger than character count: Entire string is returned.
Negative: Starting position counted from right to left, e.g. -1 = First part of the string ends before the last character
Smaller than minus number of characters in the string: Begins with 1st character
The function name ending '... include' will be ignored here.

Alt. 2
input
string starting matching pattern

Function outside ...: First part of the string ends including the starting matching pattern.
Function outside exclude ...: First part of the string ends before the starting matching pattern.
Empty matching pattern: First part of the string is blank.

Matching patterns are case-sensitive.
Attention: The matching pattern parameter distinguishes between strings and softquoted strings. In softquoted strings, following wildcard symbols act as placeholders: '?' for any character, '#' for any digit and '^' for any letter.

3
input
numeral character count or ending character position

For function names outside and outside exclude, this parameter specifies the number of characters to skip before incling the 2nd part of string.
Zero: No characters to skip. Entire string is returned.
Negative numbers are treated as zero.
Large character counts going beyond the end of the input string results to no 2nd part of the string included

For function names outside until and outside until include, this parameter specifies the ending position in the input string and is seen as starting point for the 2nd part of the string.
Character positions before the starting position of found pattern will return empty strings or at least the string matched with the matching patter (applicable to middle until include).
Negative position numbers count from the last character position leftward.

Alt. 3
input
string ending matching pattern

Function outside ...: outside part of the string includes the ending matching pattern.
Function outside exclude ...: outside part of the string excludes the ending matching pattern.

Attention: The function names ending outside until combined with matching patterns provided will assert errors.
Attention: The matching pattern parameter distinguishes between strings and softquoted strings. In softquoted strings, following wildcard symbols act as placeholders: '?' for any character, '#' for any digit and '^' for any letter.

Return value

TypeDescription
string Extracted substring

Examples

      st[] = "The taste of the coffee!";

      echo( outside( st[], 13, 4 ), " / ",  outside until ( st[], 4, -8 ) );
      echo( outside( st[], 99, 1 ), " / ",  outside until ( st[],  99, 8 ) ); // full strings
      echo( outside( st[], -99, 8 ), " / ", outside until ( st[], -99, 8 ) ); // Begins at 0

      echo;
      echo( outside( st[], ' taste', 7 ), " / ", outside exclude( st[], 'taste ', 7 ) ); // "of the coffee", "tast of the coffee"
      echo( outside( st[], ' taste', 0 ), " / ", outside exclude( st[], 'taste ', 0 ) ); // full string, and without taste
      echo;
      echo( outside ( st[], 'taste', ' the' ), " / ", outside exclude( st[], 'taste ', 'the ' ) ); //

Output

The taste of coffee! / The coffee!
The taste of the coffee! / The taste of the coffee!
e of the coffee! /  of the coffee!

The taste coffee! / The coffee!
The taste of the coffee! / The taste of the coffee!

The taste the coffee! / The coffee!
Try it yourself: Open LIB_Function_outside.b4p in B4P_Examples.zip. Decompress before use.

See also

left [string function]
right [string function]
middle [string function]
outside [parameter set function]