Way to cut/sub a string? This should be simple...

  • Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the comminuty!

    Now, what are you waiting for? Join the community now!

  • LOOKING FOR A VERSION OF SKRIPT?

    You can always check out skUnity Downloads for downloads and any other information about Skript!

Status
Not open for further replies.

mccrafter1212

Member
Jul 16, 2017
11
0
0
23
Let's assume I have this code:

code_language.skript:
set {specialString} to "This is a special string"

How can I get the last word in that string and set that to a variable?
 
Let's assume I have this code:

code_language.skript:
set {specialString} to "This is a special string"

How can I get the last word in that string and set that to a variable?
There is some methode. For easy way:

code_language.skript:
set {_S::*} to {specialString} split at " "
set {_s} to size of {_S::*}
send "This is last word: %{_s::%{_s}%}%"
 
Or, use this:
code_language.skript:
set {_last-word} to subtext of {specialString} from (last index of " " in {specialString} + 1) to {specialString}'s length
 
There is some methode. For easy way:

code_language.skript:
set {_S::*} to {specialString} split at " "
set {_s} to size of {_S::*}
send "This is last word: %{_s::%{_s}%}%"
If using this method its much easier just to do
code_language.skript:
set {_s} to last element out of split {_string} at " "
 
Status
Not open for further replies.