Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

.NET 

Splitting strings

this is a very basic tutorial i made because i have seen many people failing at this simple task ...
lets say you got this string "this is / a string" but you only want "this is" , here is what you do
Code
dim _str as string = "this is / a string"
dim temp = _srt.split("/") ' it will split the string by this character "/"
dim result as string = _srt(0) '0 is the first part , 1 is the second part and so on

another example of splitting by a word this time
the string this time is "abcd[www]efgh" , you need both the abcd part and the efgh on a separate strings
Code
dim _str as string = "abcd[www]efgh"
dim temp = _str.split("[www]")
dim first as string = temp(0)
dim second as string = temp(1)

thanks for viewing , hope that i have helped you.
(May 26, 2015 10:59 AM)halearn Wrote:  this is a very basic tutorial i made because i have seen many people failing at this simple task ...
lets say you got this string "this is / a string" but you only want "this is" , here is what you do
Code
dim _str as string = "this is / a string"
dim temp = _srt.split("/") ' it will split the string by this character "/"
dim result as string = _srt(0) '0 is the first part , 1 is the second part and so on

thanks for viewing , hope that i have helped you.

might want to edit it into a working tut at least :)

Your refrenced var is temp not _srt(0)
I wouldn't call this a tutorial to be honest
That's pretty much what is on msdn.
Why not expanding the tutorial a bit and explaining how Regex.Split() works and also talk about joining strings back together etc ;) ?
[C#/C++/Asm Coder]
Reverse Engineering / .Net security
Lol the tutorial won't even work.
You did "_srt(0)" while it should be "temp(0)". And temp should be a "String()", not a "String".
(May 26, 2015 11:16 AM)Ninja Wrote:  Lol the tutorial won't even work.
You did "_srt(0)" while it should be "temp(0)". And temp should be a "String()", not a "String".

He's a fucking idiot but 'temp' is a String() there.

Anyway, i guess we may have a moderator next year to cleanup this shit.
(May 27, 2015 08:43 AM)He B TeMy Wrote:  He's a fucking idiot but 'temp' is a String() there.

Anyway, i guess we may have a moderator next year to cleanup this shit.

What happened to the last mod?

Thought it was SomeWhiteguy?
(May 27, 2015 09:37 AM)sweetysuckscock Wrote:  What happened to the last mod?

Thought it was SomeWhiteguy?

The last one AFAIK was TUP, but he 'quit' shortly after.
(May 27, 2015 10:36 AM)He B TeMy Wrote:  The last one AFAIK was TUP, but he 'quit' shortly after.
This, I think he resigned due to exams or something.
Skype: happy.cbb
0x38E6A0912657E
(May 27, 2015 10:36 AM)He B TeMy Wrote:  The last one AFAIK was TUP, but he 'quit' shortly after.

Guess he got pissed with all the shit that goes with the job lol.

shame tho :( we do need a mod
(May 27, 2015 10:55 AM)sweetysuckscock Wrote:  Guess he got pissed with all the shit that goes with the job lol.

shame tho :( we do need a mod
No, he seems pretty tolerant; he was just extremely busy so his mod status just came at a bad time.
Skype: happy.cbb
0x38E6A0912657E
(May 27, 2015 11:02 AM)Hiiro Wrote:  No, he seems pretty tolerant; he was just extremely busy so his mod status just came at a bad time.

Yeah i'm surprised he took it, as i know he is a very good coder and properly has a million and one projects on the go all the time.

Learnt from quite a few of his sources tbh. Nice guy always shared his knowledge.
(May 26, 2015 11:02 AM)sweetysuckscock Wrote:  might want to edit it into a working tut at least :)

Your refrenced var is temp not _srt(0)

Hmmmmm...

Dim MySplitString as stringt = "1|2|3"

textbox1.text = MySplitString.tostring.split("|")(0)
textbox2.text = MySplitString.tostring.split("|")(1)
textbox3.text = MySplitString.tostring.split("|")(2)
(May 27, 2015 11:20 AM)irasch007 Wrote:  Hmmmmm...

Dim MySplitString as stringt = "1|2|3"

textbox1.text = MySplitString.tostring.split("|")(0)
textbox2.text = MySplitString.tostring.split("|")(1)
textbox3.text = MySplitString.tostring.split("|")(2)

now do that on more 100+ lines...

have fun typing.... :)

Also "MySplitString" is sting no need to ".ToString()" a string.

actually what you on about?

check the quote in my post for the original code he used if not changed yet.
(May 27, 2015 11:20 AM)irasch007 Wrote:  Hmmmmm...

Dim MySplitString as stringt = "1|2|3"

textbox1.text = MySplitString.tostring.split("|")(0)
textbox2.text = MySplitString.tostring.split("|")(1)
textbox3.text = MySplitString.tostring.split("|")(2)

No offense but this genuinely hurts my eyes.
Imagine having to do this a lot of times.
You're splitting the string again each time, do it once and save it.
This way if you run an async task that edits the string you suddenly have different results.


Possibly Related Threads...
Thread / Author Replies Views Last Post
[.NET] by pro_fesnoobSep 24, 2022 04:24 PM 14 797 Sep 24, 2022 04:24 PM
Last Post: BinaryFox
[.NET] by webwarlock72Jan 28, 2018 12:30 PM 14 507 Jan 28, 2018 12:30 PM
Last Post: Ninja
[C#] by RhinemannSep 15, 2017 04:14 AM 8 261 Sep 15, 2017 04:14 AM
Last Post: Rhinemann