Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 345 Vote(s) - 3.53 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Using Split() To Parse Data!

#1
The main reason why I'm doing this is because I see a lot of people using RegEx, when in testing Split() has been proven to function twice as fast (if you don't believe me, I'll show screenshots from a test I can set up). It can be used to get one piece of data, or a bunch of data on the page.

[code=vbnet]'Base code for all Split() usage
'Split(datasource, pattern)(index, usually 1).Split(end char)(index, always 0)
'~~
'Example 1 - Finding Numbers in Text
Dim src As String = "Unread 99, Total 199"
Dim unr As String = Split(src, "Unread ")(1).Split(",")(0) 'gets everything after Unread , and stops at the comma.
Dim tot As String = Split(src, "Total ")(1) 'since there is nothing after, no need to add the last bit.[/code][/hide]

The issue you may be noticing is that this example only covers splitting for one item, when you may have an undefined amount. This is where some people prefer regular expressions, however it is easily accomplished with Split.

[code=vbnet]Dim src As String = "(1000) (999) (888) (777) (666)"
Dim results() As String
Dim holder As New StringBuilder 'using String would cause a ton of temporary strings to be made, making this slow
Try
For i = 0 To Integer.MaxValue 'allows for hundreds of matches to be saved
holder.Append(Split(src, "(")(i).Split(")")(0) & "|")
Next
Catch ex As Exception 'An exception will occur when you run out of matches
results = holder.ToString.Split("|") 'you can optionally use SubString to remove the ending |.
End Try[/code][/hide]

Any issues, post below. Sorry if this isn't too clear, took me forever to write this on my tablet with the damn auto correct going off :p
Reply

#2
Pretty good tutorial.
I like it, its simple explained and good for beginners.
Reply

#3
I like split simply for the fact that it is faster to code and not as complicated.
Reply

#4
Great tutorial man, thanks for posting. :>
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through