Substring method

Official Content
This documentation is valid for:

Returns a substring from a given string.

Syntax

s1.Substring( n1 [, n2])

Where:
s1
   Must be a character expression.

n1 and n2 
   Must be numeric expressions.
 

Type Returned:
Character

Scope

Objects: ProcedureData ProviderTransactionWeb PanelPanel
Generators: .NET, Java, RPG, Cobol, AndroidApple

Description

Returns a substring of s1 beginning at position n1, with a length of n2 characters.

Considerations

If n2 = 0 an empty string is returned.
Omitting n2 is equivalent to setting it to s1.length() - n1 + 1. 

Constraints (not apply to .NET, Java and Ruby)

  • 1 <= s1 length <= 255
  • 0 < n1 <= s1 length
  • n2 >= 0

Samples

&Txt = '1234567890'
&Substr = &Txt.Substring(5,2)  // Result: &Substr = '56'

Availability

Omitting n2 is possible since GeneXus 15 Upgrade 7.

See Also

Concat function
Str function