Hello,
I am trying to write a regular expresssion which validates
against the URL and the textfield has 'http://' prefilled. I either
want a valid URL or just leave the 'http://' as it is. I figured an
expression for URL which is --- "http(s)?://([\w-]+\.)+[\w-]+(/[\w-
../?%&=]*)?"
I am unable to group it based on the above condition. Any help would be
great!
Thanks,
Sam. 8 1872
Hi Sam,
There really is no absolutely flawless way of parsing a URL using a Regex,
IIRC. I believe it's because there are so many possibilities for what makes
a url valid.
I usually try to parse a url by passing it to the constructor of System.Uri.
Then, you can access the different parts programmatically through different
properties and methods, without the use of "grouping".
--
Dave Sexton
<sr*****@mailcity.comwrote in message
news:11**********************@l12g2000cwl.googlegr oups.com...
Hello,
I am trying to write a regular expresssion which validates
against the URL and the textfield has 'http://' prefilled. I either
want a valid URL or just leave the 'http://' as it is. I figured an
expression for URL which is --- "http(s)?://([\w-]+\.)+[\w-]+(/[\w-
./?%&=]*)?"
I am unable to group it based on the above condition. Any help would be
great!
Thanks,
Sam. sr*****@mailcity.com wrote:
I am trying to write a regular expresssion which validates
against the URL and the textfield has 'http://' prefilled. I either
want a valid URL or just leave the 'http://' as it is. I figured an
expression for URL which is --- "http(s)?://([\w-]+\.)+[\w-]+(/[\w-
./?%&=]*)?"
I am unable to group it based on the above condition. Any help would be
great!
As I understand your question, you want to be able to match both www.midnightbeach.com and http://www.midnightbeach.com, and have the
regex automatically add the http:// to the first match.
I don't believe you can actually do this. However, you can write a
regex that will match a full or partial URL, and will group the part
after the "http://". Then, you can read the group, knowing it will
never capture "http://", and can thus simply always add "http://" to
the capture.
--
..NET 2.0 for Delphi Programmers www.midnightbeach.com/.net
What you need to know.
I apologize for the confusion.. let me clarify the issue.. I have a
textbox prefilled with http://
And, I am looking for a regular expression which is a valid URL like http://www.google.com or just leave http:// in the textbox.
Thanks,
Sam.
Jon Shemitz wrote:
sr*****@mailcity.com wrote:
I am trying to write a regular expresssion which validates
against the URL and the textfield has 'http://' prefilled. I either
want a valid URL or just leave the 'http://' as it is. I figured an
expression for URL which is --- "http(s)?://([\w-]+\.)+[\w-]+(/[\w-
./?%&=]*)?"
I am unable to group it based on the above condition. Any help would be
great!
As I understand your question, you want to be able to match both www.midnightbeach.com and http://www.midnightbeach.com, and have the
regex automatically add the http:// to the first match.
I don't believe you can actually do this. However, you can write a
regex that will match a full or partial URL, and will group the part
after the "http://". Then, you can read the group, knowing it will
never capture "http://", and can thus simply always add "http://" to
the capture.
--
.NET 2.0 for Delphi Programmers www.midnightbeach.com/.net
What you need to know.
sr*****@mailcity.com wrote:
I apologize for the confusion.. let me clarify the issue.. I have a
textbox prefilled with http://
And, I am looking for a regular expression which is a valid URL like http://www.google.com or just leave http:// in the textbox.
Sorry, I don't understand the clarification. Perhaps you could give
some examples?
--
..NET 2.0 for Delphi Programmers www.midnightbeach.com/.net
What you need to know.
I have a form which has a textbox for the user to input the URL and it
is prefilled with http://. Now, the regular expression has to validate
the url based on the expression from the previous post if the user
enters the url or accept the default value ( http://) as a valid value.
Say txtURL has http://
with a regular expression, i would want to have http://www.google.com
as valid and also http:// as valid.
Thanks,
Sam
Jon Shemitz wrote:
sr*****@mailcity.com wrote:
I apologize for the confusion.. let me clarify the issue.. I have a
textbox prefilled with http://
And, I am looking for a regular expression which is a valid URL like http://www.google.com or just leave http:// in the textbox.
Sorry, I don't understand the clarification. Perhaps you could give
some examples?
--
.NET 2.0 for Delphi Programmers www.midnightbeach.com/.net
What you need to know.
In article <Oc**************@TK2MSFTNGP04.phx.gbl>,
Dave Sexton <dave@jwa[remove.this]online.comwrote:
: There really is no absolutely flawless way of parsing a URL using a
: Regex, IIRC. I believe it's because there are so many possibilities
: for what makes a url valid.
: [...]
See Appendix B of RFC 2396: http://www.ietf.org/rfc/rfc2396.txt
Hope this helps,
Greg
--
Last week, for example, Victor David Hansen credits Bush's Iraq war for
"bringing consensual government into the heart of Middle Eastern autocracy."
That's a really stupid way to describe martial law imposed by a foreign
military conquering power . . . -- Jeffrey A. Tucker
Hi Greg,
Thanks, that's a good expression to keep on hand.
^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?
Although it isn't complete since it only handles the RFC-compliant URIs.
For example, it won't handle the following which works in Windows Explorer
and IE: ftp://me:my****@mysite.com
I use the syntax above from time to time. IE7 no longer supports that
syntax for the http protocol, but IE3+ did.
--
Dave Sexton
"Greg Bacon" <gb****@hiwaay.netwrote in message
news:12*************@corp.supernews.com...
In article <Oc**************@TK2MSFTNGP04.phx.gbl>,
Dave Sexton <dave@jwa[remove.this]online.comwrote:
: There really is no absolutely flawless way of parsing a URL using a
: Regex, IIRC. I believe it's because there are so many possibilities
: for what makes a url valid.
: [...]
See Appendix B of RFC 2396: http://www.ietf.org/rfc/rfc2396.txt
Hope this helps,
Greg
--
Last week, for example, Victor David Hansen credits Bush's Iraq war for
"bringing consensual government into the heart of Middle Eastern
autocracy."
That's a really stupid way to describe martial law imposed by a foreign
military conquering power . . . -- Jeffrey A. Tucker
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: ahaque38 |
last post by:
Hello.
Using A2K SP3, I am having the following problem with a report using
"Sorting and Grouping".
I have recently added a grouping in the reports for
"Category2<>'CONTRACTS'".
I have...
|
by: IKAS |
last post by:
I am having some difficulty in using Regular expression in .NET with
C#.
How do I write a regular expression so that it will match both the
following strings and also get me the relevant named...
|
by: Buddy |
last post by:
Can someone please show me how to create a regular expression to do the
following
My text is set to
MyColumn{1, 100} Test
I want a regular expression that sets the text to the following...
|
by: Ahmad A. Rahman |
last post by:
Hi all,
I have a problem constructing a regular expression using .net.
I have a string, separated with comma, and I want to group the string
together but, I failed to group a numeric character...
|
by: Laser Lu |
last post by:
Hi, all,
Does any body know how to use this Grouping Construct?
(?> )
The following is its description in the MSDN reference:
Nonbacktracking subexpression (also known as a "greedy"...
|
by: Laser Lu |
last post by:
Hello, everybody,
do you know how to use this Grouping Construct?
(?> )
I've found its reference on MSDN, but still can not understand it totally.
The following is its description:
...
|
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 words, when I apply ^(.+)(?=\s*).*\1 to " HEART...
|
by: Tom |
last post by:
- matches "a", "b", or "c"
- matches anything except "a", "b", and "c"
(abc) - matches "abc", with back reference
??? - matches anything except "abc" literally?? What is the syntax for
this...
|
by: sqlbraindead |
last post by:
The problem is if I want to group my database on the time basis, how can reconcile the grouping of two different criteria structure?
This is an example.
Two table I want to use these to get a...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
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...
|
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...
|
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,...
|
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...
| |