String Text Splice

Hello, is there a way to splice a text similar to javascript:

def string = ‘ThisString’;
println(string.slice(0,4));

expecting ‘This’ to be returned

Error:

def string = ‘ThisString’;
println(string.substring(0,4));

Thank you - your method worked!