C
C#•2y ago
Kekke

How do I split these strings?

If I have these inputs, wich could be random numbers. How do I split the string into two parts where the middle "-" is the where the split happens? I will use the splits in a fraction calculator. "2/3 - 2/-3" "2/-3 - 2/3" "2/3 - 2/3" "-2/-3 - 2/-3"
31 Replies
Unknown User
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
Kekke
Kekke•2y ago
Is there anyway to split the string in only two items?
Unknown User
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
Kekke
Kekke•2y ago
Ok, but if the string is "4523/-43 - 423/5542" Im kinda stuck because these inputs are userinputs
Unknown User
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
Kekke
Kekke•2y ago
okey, thanks. i i'll try to search for the "-" in the middle somehow 😛 thanks
sunder.cc
sunder.cc•2y ago
You can limit the amount of splits by giving an int as secondary parameter in the split function That way it wil only split on the first occurance of that character
Unknown User
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
Kekke
Kekke•2y ago
Exactly.
sunder.cc
sunder.cc•2y ago
<:Remi_WTF:1007450914648490014> Ehm
Unknown User
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
sunder.cc
sunder.cc•2y ago
hmmm
Kekke
Kekke•2y ago
The "-" in the middle is used as a operator. or will be used as an operator.
sunder.cc
sunder.cc•2y ago
Can you change the separator?
Kekke
Kekke•2y ago
@Lurch No It will not have space hyphon space. thats just how i wrote it, im sorry. ex : input = 2/-3-2/3 The middle "-" is where i need the split to occure.
sunder.cc
sunder.cc•2y ago
A separator should only occure where you want it to be separated, which is not the case here So separating wont be easy
Kekke
Kekke•2y ago
hmmm.. ok.
sunder.cc
sunder.cc•2y ago
If you can change the separator i would change it to something like & Then you can use the split function If you can't change it then there's not really a reliable method that I'm aware of to split it
Unknown User
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
Kekke
Kekke•2y ago
Ok, thanks ! 🙂
Unknown User
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
Kekke
Kekke•2y ago
i'll try that, thanks for the help. ! 🙂
Unknown User
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
ero
ero•2y ago
Bruh Tuple in current year
Unknown User
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
ero
ero•2y ago
rip speed
Unknown User
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
ero
ero•2y ago
because Tuple is an actually completely unnecessary allocation
Unknown User
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
ero
ero•2y ago
ValueTuple is the modern equivalent it's a struct unlike Tuple, so it doesn't allocate
Unknown User
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
Want results from more Discord servers?
Add your server
More Posts