Jump to content
Xtreme .Net Talk

Recommended Posts

Posted (edited)

ok my application get a string passed to is, but i only need a small part of it so how do i get it?

GET /index.htm HTTP/1.1

Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*

Accept-Language: en-us

Accept-Encoding: gzip, deflate

User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322)

Host: schrauwen.no-ip.org:81

Connection: Keep-Alive

Cookie: useralb=Friends%2FSofie; isadmin=1; member_id=1; pass_hash=fc86d40ab841bf68d020223175187e65

I would like to get some information from that like:

the filename and path after GET,

User-Agent, and Cookies

Edited by jorge
Posted

Regular Expressions are really powerful for identifying areas in strings. Here's a simple example:

 


Dim s As String = tvwBillOfMaterial.SelectedNode.Text
Dim re As New System.Text.RegularExpressions.Regex("\(\d+\.?\d?\d?\d?\d?")  'finds the quantity from the nodes description string
Dim m As System.Text.RegularExpressions.Match = re.Match(s)
Quantity_From_Node_Description = m.ToString

Hope it helps

Posted

There are various was to go about this depending on the rigidity of the string.

 

There are two useful functions here; myString.SubString and myString.IndexOf. The former returns part of the string, where you specify the first character to get, and optionally how many characters from that point to get. IndexOf returns the first index of a specific character or string.

 

So, for example, you could Get the first index of "GET", the first index of HTTP, and get the characters between that.

 

edit: or you could use regex :P

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...