Function
substring(_:_:_:)
Extracts a substring from a string.
func substring(_ string: any EcoreValue, _ start: any EcoreValue, _ end: any EcoreValue) throws -> EString
Parameters
string-
The source string
start-
The starting index (1-based, inclusive)
end-
The ending index (1-based, exclusive)
Return Value
The extracted substring
Discussion
The substring operation returns a portion of the original string, starting at the specified start index and ending before the end index. Indices are 1-based as per OCL specification.
Examples
let text = "Hello World" as EString
let sub = try substring(text, 1, 5) // Result: "Hell"
let sub2 = try substring(text, 7, 12) // Result: "World"