472,328 Members | 1,108 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

Regular expression question?

My web application allow the user to enter the site by typing in a subdomain
such as 'name.domain.com'. However, I want to retrieve just the 'name' part
of the subdomain. see code below (the equal sign '=' respresent the value
I'm getting when I run the code)

Test 1.........................name.domain.com
Dim sdmlink As String = Request.Url.ToString

Dim sdm As Regex

sdm = New Regex("http://(?!www\.)(.*)(\.domain\.com.*)")

Context.Items("Test") = (sdm.Replace(sdmlink, "$1")) ---->> =
http://name.doman.com/welcome.aspx ---- this should = name

Test 2................name.domain.com
Dim sdmlink As String = Request.Url.ToString

Dim sdm As Regex

sdm = New Regex("http://(?!www\.)(.*)(\.domain\.com.*)")

Context.Items("Test") = (sdm.Replace(sdmlink,
"test/default.aspx?Id=$1")) ---->> = test/default.aspx?Id=name ---- this is
correct


Nov 19 '05 #1
8 1338
I think you are realy strugling with this. Its best to keep it to the same
post and not post each question seperatly.

Context.Items("Test") = (sdm.Replace(sdmlink, "$1")) ---->> = http://name.doman.com/welcome.aspx ---- this should = name

You've got a spelling mistake :

name.domAn.com should be name.domAIn.com
^ ^^

if its domAIn the result is correct : name

Let me know if you have any more questions..

Cheers,
Tom Pester
My web application allow the user to enter the site by typing in a
subdomain such as 'name.domain.com'. However, I want to retrieve just
the 'name' part of the subdomain. see code below (the equal sign '='
respresent the value I'm getting when I run the code)

Test 1.........................name.domain.com
Dim sdmlink As String = Request.Url.ToString
Dim sdm As Regex

sdm = New Regex("http://(?!www\.)(.*)(\.domain\.com.*)")

Context.Items("Test") = (sdm.Replace(sdmlink, "$1")) ---->> =
http://name.doman.com/welcome.aspx ---- this should = name

Test 2................name.domain.com
Dim sdmlink As String = Request.Url.ToString
Dim sdm As Regex

sdm = New Regex("http://(?!www\.)(.*)(\.domain\.com.*)")

Context.Items("Test") = (sdm.Replace(sdmlink,
"test/default.aspx?Id=$1")) ---->> = test/default.aspx?Id=name ----
this is correct

Nov 19 '05 #2
Yes, I'm struggling, but....
No it's not the spelling. I think the regex expression is not recognizing
the url. what do you think?
I ready do appreciate all the help. Thanks
Sub Application_BeginRequest(ByVal sender As Object, ByVal e As EventArgs)

' Fires at the beginning of each request

Dim sdmurl As String = Request.Url.ToString

Dim sdm As Regex

sdm = New Regex("http://(?!www\.)(.*)(\.domain\.com.*)")

Context.Items("Test") = (sdm.Replace(sdmurl, "/welcome.aspx?Id=$1"))

End Sub
<to********************@pandora.be> wrote in message
news:a1**************************@news.microsoft.c om...
I think you are realy strugling with this. Its best to keep it to the same
post and not post each question seperatly.

Context.Items("Test") = (sdm.Replace(sdmlink, "$1")) ---->> =
http://name.doman.com/welcome.aspx

---- this should = name

You've got a spelling mistake :
name.domAn.com should be name.domAIn.com ^
^^

if its domAIn the result is correct : name

Let me know if you have any more questions..

Cheers,
Tom Pester
My web application allow the user to enter the site by typing in a
subdomain such as 'name.domain.com'. However, I want to retrieve just
the 'name' part of the subdomain. see code below (the equal sign '='
respresent the value I'm getting when I run the code)

Test 1.........................name.domain.com
Dim sdmlink As String = Request.Url.ToString
Dim sdm As Regex

sdm = New Regex("http://(?!www\.)(.*)(\.domain\.com.*)")

Context.Items("Test") = (sdm.Replace(sdmlink, "$1")) ---->> =
http://name.doman.com/welcome.aspx ---- this should = name

Test 2................name.domain.com
Dim sdmlink As String = Request.Url.ToString
Dim sdm As Regex

sdm = New Regex("http://(?!www\.)(.*)(\.domain\.com.*)")

Context.Items("Test") = (sdm.Replace(sdmlink,
"test/default.aspx?Id=$1")) ---->> = test/default.aspx?Id=name ----
this is correct


Nov 19 '05 #3
Hi Leon,

I ran the code below and added the ouput as comments

Dim sdmlink As String = "http://name.domain.com/welcome.aspx"
Dim sdm As New Regex("http://(?!www\.)(.*)(\.domain\.com.*)")
Response.Write("result : " & sdm.Replace(sdmlink, "test/default.aspx?Id=$1")
& "<BR>")
' result : test/default.aspx?Id=name

The regex correctly extracts "name" and the code produces "test/default.aspx?Id=name".
This is what you want no?

I think you are tring to say that there are certain inputs that dont give
the correct result. Otherwise I dont understand your problem.

The input above is

Dim sdmlink As String = "http://name.domain.com/welcome.aspx"

What kind of inputs dont work for you?
Cheers,
Tom Pester
Yes, I'm struggling, but....
No it's not the spelling. I think the regex expression is not
recognizing
the url. what do you think?
I ready do appreciate all the help. Thanks
Sub Application_BeginRequest(ByVal sender As Object, ByVal e As
EventArgs)
' Fires at the beginning of each request

Dim sdmurl As String = Request.Url.ToString

Dim sdm As Regex

sdm = New Regex("http://(?!www\.)(.*)(\.domain\.com.*)")

Context.Items("Test") = (sdm.Replace(sdmurl, "/welcome.aspx?Id=$1"))

End Sub

<to********************@pandora.be> wrote in message
news:a1**************************@news.microsoft.c om...
I think you are realy strugling with this. Its best to keep it to the
same post and not post each question seperatly.
Context.Items("Test") = (sdm.Replace(sdmlink, "$1")) ---->> =
http://name.doman.com/welcome.aspx

---- this should = name

You've got a spelling mistake :
name.domAn.com should be name.domAIn.com ^
^^
if its domAIn the result is correct : name

Let me know if you have any more questions..

Cheers,
Tom Pester
My web application allow the user to enter the site by typing in a
subdomain such as 'name.domain.com'. However, I want to retrieve
just the 'name' part of the subdomain. see code below (the equal
sign '=' respresent the value I'm getting when I run the code)

Test 1.........................name.domain.com
Dim sdmlink As String = Request.Url.ToString
Dim sdm As Regex
sdm = New Regex("http://(?!www\.)(.*)(\.domain\.com.*)")

Context.Items("Test") = (sdm.Replace(sdmlink, "$1")) ---->> =
http://name.doman.com/welcome.aspx ---- this should = name

Test 2................name.domain.com
Dim sdmlink As String = Request.Url.ToString
Dim sdm As Regex
sdm = New Regex("http://(?!www\.)(.*)(\.domain\.com.*)")

Context.Items("Test") = (sdm.Replace(sdmlink,
"test/default.aspx?Id=$1")) ---->> = test/default.aspx?Id=name ----
this is correct

Nov 19 '05 #4
What kind of inputs don't work for you?
---> you hit the correct input on the head
http://name.domain.com/welcome.aspx -or- http://name.domain.com/

result : test/default.aspx?Id=name
The regex correctly extracts "name" and the code produces
"test/default.aspx?Id=name".
---> perfect that is the exact results I'm looking for almost, but..

This is what you want no?
--->how do I extract just 'name' -not- 'test/default.aspx?Id=name'

Thanks alot tom!

<to********************@pandora.be> wrote in message
news:a1**************************@news.microsoft.c om...
Hi Leon,

I ran the code below and added the ouput as comments

Dim sdmlink As String = "http://name.domain.com/welcome.aspx"
Dim sdm As New Regex("http://(?!www\.)(.*)(\.domain\.com.*)")
Response.Write("result : " & sdm.Replace(sdmlink,
"test/default.aspx?Id=$1") & "<BR>")
' result : test/default.aspx?Id=name

The regex correctly extracts "name" and the code produces
"test/default.aspx?Id=name". This is what you want no?

I think you are tring to say that there are certain inputs that dont give
the correct result. Otherwise I dont understand your problem.

The input above is
Dim sdmlink As String = "http://name.domain.com/welcome.aspx"

What kind of inputs dont work for you?
Cheers,
Tom Pester
Yes, I'm struggling, but....
No it's not the spelling. I think the regex expression is not
recognizing
the url. what do you think?
I ready do appreciate all the help. Thanks
Sub Application_BeginRequest(ByVal sender As Object, ByVal e As
EventArgs)
' Fires at the beginning of each request

Dim sdmurl As String = Request.Url.ToString

Dim sdm As Regex

sdm = New Regex("http://(?!www\.)(.*)(\.domain\.com.*)")

Context.Items("Test") = (sdm.Replace(sdmurl, "/welcome.aspx?Id=$1"))

End Sub

<to********************@pandora.be> wrote in message
news:a1**************************@news.microsoft.c om...
I think you are realy strugling with this. Its best to keep it to the
same post and not post each question seperatly.

Context.Items("Test") = (sdm.Replace(sdmlink, "$1")) ---->> =
http://name.doman.com/welcome.aspx

---- this should = name

You've got a spelling mistake :
name.domAn.com should be name.domAIn.com ^
^^
if its domAIn the result is correct : name

Let me know if you have any more questions..

Cheers,
Tom Pester
My web application allow the user to enter the site by typing in a
subdomain such as 'name.domain.com'. However, I want to retrieve
just the 'name' part of the subdomain. see code below (the equal
sign '=' respresent the value I'm getting when I run the code)

Test 1.........................name.domain.com
Dim sdmlink As String = Request.Url.ToString
Dim sdm As Regex
sdm = New Regex("http://(?!www\.)(.*)(\.domain\.com.*)")

Context.Items("Test") = (sdm.Replace(sdmlink, "$1")) ---->> =
http://name.doman.com/welcome.aspx ---- this should = name

Test 2................name.domain.com
Dim sdmlink As String = Request.Url.ToString
Dim sdm As Regex
sdm = New Regex("http://(?!www\.)(.*)(\.domain\.com.*)")

Context.Items("Test") = (sdm.Replace(sdmlink,
"test/default.aspx?Id=$1")) ---->> = test/default.aspx?Id=name ----
this is correct


Nov 19 '05 #5
> --->how do I extract just 'name' -not- 'test/default.aspx?Id=name'

Strange that you ask this because you yourself add it in the code :

Dim sdmlink As String = "http://name.domain.com/welcome.aspx"
Dim sdm As New Regex("http://(?!www\.)(.*)(\.domain\.com.*)")
Response.Write("result : " & sdm.Replace(sdmlink, "test/default.aspx?Id=$1")
& "<BR>")
' result : test/default.aspx?Id=name

your replace with : "test/default.aspx?Id=$1"

if you just want "name" do this :

Dim sdmlink As String = "http://name.domain.com/welcome.aspx"
Dim sdm As New Regex("http://(?!www\.)(.*)(\.domain\.com.*)")
Response.Write("result : " & sdm.Replace(sdmlink, "$1") & "<BR>") '
' result : name

But we already posted this.

I cleaner way to get the "name" is like this :

Dim sdmlink As String = "http://name.domain.com/welcome.aspx"
Dim sdm As New Regex("http://(?!www\.)(.*)(\.domain\.com.*)")
Response.Write(sdm.Match(sdmlink).Groups(1))
' result : name

This produces only "name"

I added you to my msn cause I think your english isnt conversation quality
(no offence :)
If you still can't continue lets have a chat
Nov 19 '05 #6
oh I see the problem, but don't know exactly how to fix it...see below

the follow code runs perfect when you pre include the url see... ---->>
http://name.domain.com/welcome.aspx
Dim sdmlink As String = "http://name.domain.com/welcome.aspx"
Dim sdm As New Regex("http://(?!www\.)(.*)(\.domain\.com.*)")
Response.Write("result : " & sdm.Replace(sdmlink, "$1")
' result : name

but what if you get the url in realtime request.url.tostring ---->
request.url.tostring
Dim sdmlink As String = request.url.tostring
Dim sdm As New Regex("http://(?!www\.)(.*)(\.domain\.com.*)")
Response.Write("result : " & sdm.Replace(sdmlink, "$1")
' result : the requested url

I added you to my msn cause I think your english isnt conversation quality
no offence :)
*Cool I don't see that you have added me. No offence taken :)

<to********************@pandora.be> wrote in message
news:a1**************************@news.microsoft.c om...
--->how do I extract just 'name' -not- 'test/default.aspx?Id=name'


Strange that you ask this because you yourself add it in the code :

Dim sdmlink As String = "http://name.domain.com/welcome.aspx"
Dim sdm As New Regex("http://(?!www\.)(.*)(\.domain\.com.*)")
Response.Write("result : " & sdm.Replace(sdmlink,
"test/default.aspx?Id=$1") & "<BR>")
' result : test/default.aspx?Id=name

your replace with : "test/default.aspx?Id=$1"

if you just want "name" do this :

Dim sdmlink As String = "http://name.domain.com/welcome.aspx"
Dim sdm As New Regex("http://(?!www\.)(.*)(\.domain\.com.*)")
Response.Write("result : " & sdm.Replace(sdmlink, "$1") & "<BR>") ' '
result : name

But we already posted this.

I cleaner way to get the "name" is like this :

Dim sdmlink As String = "http://name.domain.com/welcome.aspx"
Dim sdm As New Regex("http://(?!www\.)(.*)(\.domain\.com.*)")
Response.Write(sdm.Match(sdmlink).Groups(1))
' result : name

This produces only "name"

I added you to my msn cause I think your english isnt conversation quality
(no offence :)
If you still can't continue lets have a chat.

Nov 19 '05 #7
I got it thanks!

"Leon" <vn*****@msn.com> wrote in message
news:eJ**************@TK2MSFTNGP10.phx.gbl...
oh I see the problem, but don't know exactly how to fix it...see below

the follow code runs perfect when you pre include the url see... ---->>
http://name.domain.com/welcome.aspx
Dim sdmlink As String = "http://name.domain.com/welcome.aspx"
Dim sdm As New Regex("http://(?!www\.)(.*)(\.domain\.com.*)")
Response.Write("result : " & sdm.Replace(sdmlink, "$1")
' result : name

but what if you get the url in realtime request.url.tostring ---->
request.url.tostring
Dim sdmlink As String = request.url.tostring
Dim sdm As New Regex("http://(?!www\.)(.*)(\.domain\.com.*)")
Response.Write("result : " & sdm.Replace(sdmlink, "$1")
' result : the requested url

I added you to my msn cause I think your english isnt conversation quality
no offence :)
*Cool I don't see that you have added me. No offence taken :)

<to********************@pandora.be> wrote in message
news:a1**************************@news.microsoft.c om...
--->how do I extract just 'name' -not- 'test/default.aspx?Id=name'


Strange that you ask this because you yourself add it in the code :

Dim sdmlink As String = "http://name.domain.com/welcome.aspx"
Dim sdm As New Regex("http://(?!www\.)(.*)(\.domain\.com.*)")
Response.Write("result : " & sdm.Replace(sdmlink,
"test/default.aspx?Id=$1") & "<BR>")
' result : test/default.aspx?Id=name

your replace with : "test/default.aspx?Id=$1"

if you just want "name" do this :

Dim sdmlink As String = "http://name.domain.com/welcome.aspx"
Dim sdm As New Regex("http://(?!www\.)(.*)(\.domain\.com.*)")
Response.Write("result : " & sdm.Replace(sdmlink, "$1") & "<BR>") ' '
result : name

But we already posted this.

I cleaner way to get the "name" is like this :

Dim sdmlink As String = "http://name.domain.com/welcome.aspx"
Dim sdm As New Regex("http://(?!www\.)(.*)(\.domain\.com.*)")
Response.Write(sdm.Match(sdmlink).Groups(1))
' result : name

This produces only "name"

I added you to my msn cause I think your english isnt conversation
quality (no offence :)
If you still can't continue lets have a chat.


Nov 19 '05 #8
And what was the problem? Rrealtime Request.url.tostring was not in the expected
format?

Cheers,
Tom Pester

PS Always isolate the poblem to the minimum before giving up on an anwser
yourself.
This means testing the problem code with your own input that you can control
easily.

I got it thanks!

"Leon" <vn*****@msn.com> wrote in message
news:eJ**************@TK2MSFTNGP10.phx.gbl...
oh I see the problem, but don't know exactly how to fix it...see
below

the follow code runs perfect when you pre include the url see...
---->>
http://name.domain.com/welcome.aspx
Dim sdmlink As String = "http://name.domain.com/welcome.aspx"
Dim sdm As New Regex("http://(?!www\.)(.*)(\.domain\.com.*)")
Response.Write("result : " & sdm.Replace(sdmlink, "$1")
' result : name
but what if you get the url in realtime request.url.tostring ---->
request.url.tostring
Dim sdmlink As String = request.url.tostring
Dim sdm As New Regex("http://(?!www\.)(.*)(\.domain\.com.*)")
Response.Write("result : " & sdm.Replace(sdmlink, "$1")
' result : the requested url
I added you to my msn cause I think your english isnt conversation
quality
no offence :)
*Cool I don't see that you have added me. No offence taken :)
<to********************@pandora.be> wrote in message
news:a1**************************@news.microsoft.c om...
--->how do I extract just 'name' -not- 'test/default.aspx?Id=name'

Strange that you ask this because you yourself add it in the code :

Dim sdmlink As String = "http://name.domain.com/welcome.aspx"
Dim sdm As New Regex("http://(?!www\.)(.*)(\.domain\.com.*)")
Response.Write("result : " & sdm.Replace(sdmlink,
"test/default.aspx?Id=$1") & "<BR>")
' result : test/default.aspx?Id=name
your replace with : "test/default.aspx?Id=$1"

if you just want "name" do this :

Dim sdmlink As String = "http://name.domain.com/welcome.aspx"
Dim sdm As New Regex("http://(?!www\.)(.*)(\.domain\.com.*)")
Response.Write("result : " & sdm.Replace(sdmlink, "$1") & "<BR>") '
'
result : name
But we already posted this.

I cleaner way to get the "name" is like this :

Dim sdmlink As String = "http://name.domain.com/welcome.aspx"
Dim sdm As New Regex("http://(?!www\.)(.*)(\.domain\.com.*)")
Response.Write(sdm.Match(sdmlink).Groups(1))
' result : name
This produces only "name"

I added you to my msn cause I think your english isnt conversation
quality (no offence :)
If you still can't continue lets have a chat.

Nov 19 '05 #9

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

Similar topics

3
by: Vibha Tripathi | last post by:
Hi Folks, I put a Regular Expression question on this list a couple days ago. I would like to rephrase my question as below: In the Python...
5
by: Bradley Plett | last post by:
I'm hopeless at regular expressions (I just don't use them often enough to gain/maintain knowledge), but I need one now and am looking for help. I...
10
by: Lee Kuhn | last post by:
I am trying the create a regular expression that will essentially match characters in the middle of a fixed-length string. The string may be any...
18
by: Q. John Chen | last post by:
I have Vidation Controls First One: Simple exluce certain special characters: say no a or b or c in the string: * Second One: I required...
5
by: Ryan | last post by:
HELLO I am using the following MICROSOFT SUGGESTED (somewhere on msdn) regular expression to validate email addresses however I understand that...
7
by: norton | last post by:
Hello, Does any one know how to extact the following text into 4 different groups(namely Date, Artist, Album and Quality)? - Artist - Album ...
7
by: Billa | last post by:
Hi, I am replaceing a big string using different regular expressions (see some example at the end of the message). The problem is whenever I apply...
6
by: Ludwig | last post by:
Hi, i'm using the regular expression \b\w to find the beginning of a word, in my C# application. If the word is 'public', for example, it works....
3
by: Zach | last post by:
Hello, Please forgive if this is not the most appropriate newsgroup for this question. Unfortunately I didn't find a newsgroup specific to...
25
by: Mike | last post by:
I have a regular expression (^(.+)(?=\s*).*\1 ) that results in matches. I would like to get what the actual regular expression is. In other...
0
by: tammygombez | last post by:
Hey everyone! I've been researching gaming laptops lately, and I must say, they can get pretty expensive. However, I've come across some great...
0
by: concettolabs | last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
0
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
0
by: CD Tom | last post by:
This happens in runtime 2013 and 2016. When a report is run and then closed a toolbar shows up and the only way to get it to go away is to right...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...

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.