473,406 Members | 2,633 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

How to extract variable + its value from URL

I have url:
www.site.com/index?a=1&b=2
www.site.com/index?a=1

and I need a regex or some solution to extract 'a' variable and its
value.

Any ideas?
joe

Nov 21 '05 #1
4 1185
Jozef,

"Jozef Jarosciak" <jo*@doprocess.com> schrieb:
I have url:
www.site.com/index?a=1&b=2
www.site.com/index?a=1

and I need a regex or some solution to extract 'a' variable and its
value.


Quick and dirty:

\\\
Dim u As New Uri("http://www.site.com/index?a=bla&b=22312")
Dim w As New HttpRequest("", u.AbsoluteUri, Mid(u.Query, 2))
MsgBox(w.QueryString.Item("a"))
MsgBox(w.QueryString.Item("b"))
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
Nov 21 '05 #2
Thanks, but when I plug this to my code, line:

Dim w As New HttpRequest("", u.AbsoluteUri, Mid(u.Query, 2))

has a word HttpRequest underlined and saying:
"Type HttpRequest is not defined"

I made sure at the top it reads:
Imports System.Web

What is wrong?
Joe

Nov 21 '05 #3
"Jozef Jarosciak" <jo*@doprocess.com> schrieb:
Thanks, but when I plug this to my code, line:

Dim w As New HttpRequest("", u.AbsoluteUri, Mid(u.Query, 2))

has a word HttpRequest underlined and saying:
"Type HttpRequest is not defined"

I made sure at the top it reads:
Imports System.Web


Make sure your project contains a reference to "System.Web.dll".

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
Nov 21 '05 #4
Ah, of course :)
Thanks a lot. It works like a charm.
Joe

Nov 21 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Luke Bellamy | last post by:
Hi, I have several types of contact forms on my web site and when submit is hit I would like the PHP code to build a string with each variable name and value and dump it in an email to me. So I...
3
by: Phil | last post by:
Hei, I'm currently trying to write a program in C# that will allow users to parametrize their queries. For instance, I have a query like this: SELECT * FROM Customers Where Region = @Region AND...
9
by: Stefan Franke | last post by:
Hi, I've got the following simple XSLT stylesheet, that lists all the values of the elements of any given XML file. <?xml version="1.0" encoding="ISO-8859-1"?> <xsl:stylesheet version="1.0"...
7
by: William Payne | last post by:
Hello, I have a variable of type unsigned long. It has a number of bits set (with set I mean they equal one). I need to determine those bits and their position and create new numbers from them. For...
9
by: Sharon | last post by:
hi, I want to extract a string from a file, if the file is like this: 1 This is the string 2 3 4 how could I extract the string, starting from the 10th position (i.e. "T") and...
1
by: Patrick Sullivan | last post by:
I am trying to extract two parts of a number from an array element. Numbers are in the format of 1.10, 2.50, 11.10, etc. Floor and ceiling won't work right because close to 1.00, I get a zero, and...
0
by: mix01 | last post by:
Hi, I am trying to get some VBA code working, but am preplex as to why it does not work. I would really appreciate any level of help. Many thanks, Mix01 Version of the program
2
by: hutch75 | last post by:
Hi All - chasing down a means to initiate a traceroute, record results, and extract IP addresses in an (array?) Here's what I'm thinking about so far, wonder if anyone's been down this road before...
1
by: Curious | last post by:
I define a variable ("result") as object. Its value is set by following code: object result = splusObject.GetType().InvokeMember("ReturnValue", System.Reflection.BindingFlags.GetProperty, null,...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.