Solved Remove all special chars from a string?

  • 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.

pepper82

Member
Jan 26, 2017
272
1
18
41
Hi all,
does anybody know how to "clean up" a string from any unwanted characters?

Example:
STRING = "Hello this &6is come cool text with %% lots of crazy // chars!"

I want to clear it so that only words and numbers are left, but no color codes or any other special char.
 
Put every individual character in a list using split, loop the list, if the character is a wanted character add it, else don't
 
  • Like
Reactions: pepper82
Code:
command /clean <text>:
    trigger:
        set {_} to "abcdefghijklmnopqrstuvwxyz0123456789"
        set {_1} to arg 1
        set {_2} to arg 1
        set {_l::*} to {_} split at ""
        loop {_l::*}:
            replace every loop-value with "" in {_1}
        set {_l2::*} to {_1} split at ""
        loop {_l2::*}:
            replace every loop-value with "" in {_2}
        message {_2}
 
  • Like
Reactions: pepper82
Status
Not open for further replies.