#Is anyone good at Regex that can help me with something kinda complex?
31 messages · Page 1 of 1 (latest)
My idea is to have a string such as @text("Hello, ")@selector("@a") and I want to find what type is next to the @ and then if it's either "text", "selector", or "score" then I want to find what's inside the ()
other string templates:
@text("Welcome, ")@selector("@s")@text(" to Bedrock Add-Ons! We hope you love it here!")
@text("Your current Money is: ")@score("name":"@s","objective":"money")
basically: Search string for @ and any valid type (text, score, selector) and then get the value inside the parenthesis () if the type is valid
then after that i'd need to get the values for the score stuff but that's for later
https://regex101.com/r/DdyA6t/1
Would this fit your use-case?
Almost but thanQ very much for the help
what I need is for it to only detect certain types
like text, selector, and score only
I set it up to do that tho
@(\w+)\((\s*"([^"\\]|\\.)*"(\s*[:,])?)+\)
...
this is what I use currently
gotta figure out how to do a few other things now
my is robust xd
you can extract keyword and argument with $1 $2
I'm just gonna use this and use a for-loop
let array = [...'@text("Welcome, ")@selector("@s\")'.matchAll(regex)]
//array
[
[ orignal, keyword, argument ],
[ orignal, keyword, argument ]
]
this is my input
the 3rd argument is the main input it takes
the first 2 are temporary
well you dont seem to know regex well use whatever u want but the one i sent is lot more advance than any other
it gets keyword, argument, escaped string, little syntax checking, without hardcore pattern
?
I've been tryna do the same thing
Except with a different syntax mine was like "Hello hi <@s> my score is <@s>kills>"
Well I will be releasing the wrapper when it has a few useful features so you can get ideas from that! 🙂