Skip to content

Instantly share code, notes, and snippets.

@javagrails
Last active December 22, 2015 03:52
Show Gist options
  • Save javagrails/1b7e6e41f893bfb34b68 to your computer and use it in GitHub Desktop.
Save javagrails/1b7e6e41f893bfb34b68 to your computer and use it in GitHub Desktop.
Groovy String Operation Examples
//How to get last 2/5 digit/char from a String
static main(args) {
String texter = "5793231309"
String texter2 = texter[-2..-1]
String texter5 = texter[-5..-1]
println(texter2) // 09
println(texter5) // 31309
}
// YOU CAN RUN CODE ONLINE HERE
// http://groovyconsole.appspot.com/
// http://www.tutorialspoint.com/execute_groovy_online.php
@javagrails
Copy link
Author

YOU CAN RUN CODE ONLINE HERE
groovyconsole
execute_groovy
:sparkles:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment