Trim everything before first space and after the second space

I’m trying to add a new field that trims everything before the first space and after the second space.

Ex. Change “ABC 11948 B” to “11948”

Try this

NewString: Text

NewString := COPYSTR(‘ABC 11948 B’, STRPOS(‘ABC 11948 B’, ’ ') + 1;
NewString := COPYSTR(NewString, STRPOS(NewString, STRPOS(NewString, ’ ') - 1;
Exit(NewString)

Or try this:

procedure GetValue(String: Text): Text
var
        ListOfText: List of [Text];
begin
        ListOfText := String.Split(' ');
        exit(ListOfText.Get(2));
end;

Or even better:

NewString := String.Split(' ').Get(2);