#remove formatting from a string/text

1 messages · Page 1 of 1 (latest)

glass vessel
#

i know that "set {var} to uncolored/unformatted {var}" exist, but they do not do anything

tender snow
#

they should?

glass vessel
#

it doesnt

#

does it unformat "&#000000" or "§#000000", or can it convert "&#000000" to "§x§0§0§0§0§0§0"

#

because it wont remove the formatting from the first two

#

and i cant figure out, nor think there is a way to convert luckperms/essentials formatting to the default

#

i dont want to have to loop through the string and replace/place things manually, as that would be too difficult

tender snow
#

use <##FFFFFF> and I think it will work

glass vessel
#

i need a way to either convert &#RRGGBB to <#RRGGBB>, or just replace all instances of &#RRGGBB with ""

#

skript only supports <#RRGGBB> format for hex codes in text

#

unfortunately

fickle ether
#

Yeah the chat format

glass vessel
fickle ether
#

Probably beacuse of adventure api

#

If i remember correctly (not sure) it only supports

#

Chat format too

glass vessel
#

apparently the "send" effect supports the format §#RRGGBB, but nowhere else in skript

#

every other plugin i know of, uses the &#RRGGBB format

fickle ether
#

Have you thought of maybe splitting after #

glass vessel
#

yes, but it would split everything. so it would be "&#" and "RRGGBBTEXT"

#

its difficult because the RRGGBB can all be different things, and so can the input text

fickle ether
#

Hm

glass vessel
#

so its going to be extremely difficult to just simply replace the format with a new one

fickle ether
#

Is it like one time send?

#

where u cant actually save it

#

Temporary

#

Like just "<#FFFFFF> hello"

glass vessel
#

im executing when a player uses a command, making a blacklist for the string argument

#

i just need to remove all the color codes, and have the text by itself, no colors

#

so "&#RRGGBBTEXT" would need to become just "TEXT"

#

so i can scan the final text for the words

fickle ether
#

You use essentialsxchat? Or you made your own chat

#

It sounds like you made your own

glass vessel
#

and yes, that technically could work, but, if players seperate letters with colors, i cannot find wordsanymore

fickle ether
#

Beacuse i dont think players can send colors just like this

glass vessel
#

i cant find "TEXT" in &#RRGGBBTE&#RRGGBBXT

glass vessel
#

im trying to detect if the luckperms prefix contains any slurs or staff titles

fickle ether
#

You could try and get 6 first values after #? But that could result in weird things if rgb was typed differently

#

Aka incorrectly for example

#

So as yoy said RRGGBB can be anything

glass vessel
#

i would need to get rid of all "&" and find 6 values after #, remove them, then remove "#"

tender snow
#

just regex find and replace &#XXXXXX

glass vessel
#

i dont care about people typing it impropperly, because their nick would just be the messed up thing, since essentials woud just use the improperly formatted text anyways

glass vessel
#

I also need to detect IF the six numbers and letters are even a part of the hex code, because someone could just type “&# words”and it would remove all of it, and its not even formatted, because of the space

tender snow
#

regexes. a bit wonky to learn at first though

fickle ether
#

&#[0-9A-Fa-f]{6} smth like this?

tender snow
#

you can use [\dA-Fa-f] for

#

yeah exactly

fickle ether
#

Just not sure how you could implement it in skript

tender snow
#

reflect

fickle ether
#

Yeah probably, thought there was regex in skript

tender snow
#

i think skbee text components also do a thing but its overcomplicated

fickle ether
#
replace [(all|every)|[the] first] %strings% with %string% in %strings% [with case sensitivity]
(replace [with|using] regex|regex replace) %strings% in %strings% with %string%
(replace [with|using] regex|regex replace) %strings% with %string% in %strings%
replace [all|every] %itemtypes% in %inventories% with %itemtype%
replace [all|every] %itemtypes% with %itemtype% in %inventories%``` saw that but idk how that regex works then
tender snow
fickle ether
#

Ah

glass vessel
#

You mind helping me with it?

fickle ether
#

x8ight seems better at it than me

glass vessel
#

I need to replace occurrences of “&#xxxxxx” in a string variable

tender snow
#

you can play around on regex101.com. I think there's some snippets in #skript-snippets as well that might detect colour codes

#

should be something like &#([\dA-Fa-f]){6} replaced with <##$1>

#

-# you can do a find & replace across ALL FILES in VS code. Just make sure you look at the preview to make SURE its correct otherwise you screw up dozens of files.
-# dont ask me how I know...

glass vessel
#

ill keep this, im busy with smt else rn, so ill test it later

glass vessel
tender snow
#

yes

glass vessel
#

its not filtering it

#

idk if im doing something wrong

#

i also need it to match numbers btw, since hex codes can have numbers

#

replace "&#([\dA-Fa-f]){6}" in {_pref} with ""

#

thats what isnt working

#

nvsm