473,394 Members | 1,866 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,394 software developers and data experts.

JS regex. Matching URL

Hello,

I am trying to find out how to create a line of JS code to do a regex to match a
URL inside a text. I don't want to know if it is valid, but just if there is a
URL inside a text.
Can anybody give me quick start on how I can acchive this? I surfed a couple of
regex sites, but could not find a solution so far.

Thank you in advance.

Merlin

PS: Is it also possible with regex to find out if the text contains just out of
High case letters? For example HELLO instead of Hello
Oct 3 '05 #1
2 2247
On 03/10/2005 11:13, Merlin wrote:
I am trying to find out how to create a line of JS code to do a regex to
match a URL inside a text. I don't want to know if it is valid, but just
if there is a URL inside a text.
It depends on the form that the URL might take (and what you want to
allow). A regular expression that accepts a full RFC 3986-compliant URL
will be very long (though not particularly complex), whereas you might
want something more restrictive. Also, will the URLs only be absolute
(including scheme), just the authority and path, or either?

[snip]
PS: Is it also possible with regex to find out if the text contains just
out of High case letters? For example HELLO instead of Hello


The easiest approach is to search for any lower-case letters.

if(!/[a-z]/.test( string )) {
/* Does not contain lower-case letters */
}

This would not check for numbers, whitespace, or punctuation.

Mike

--
Michael Winter
Prefix subject with [News] before replying by e-mail.
Oct 3 '05 #2

To check for an url in a string, is quite simple, as for cases and such, js
follows pretty much Perl regexps, so it's regexps are Perlish and they can
discriminate the pattern very keenly and quite close to exactly what you
want, so, you need to be more specific or such.
Danny
Oct 4 '05 #3

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

Similar topics

4
by: aeuglein | last post by:
Hello! I have this RegEx: /(+:\/\/+)/i Now, I want to exlude on the end of a String the formats .gif / .jpg / ..png / .exe / .zip / .rar How I can this add to my regex ?
2
by: mikea59 | last post by:
I am getting errors in XMLSpy (Pro) in the following case: Source Document: <test> 12345 AB 12345 </test> Stylesheet: <xsl:stylesheet version="2.0"...
3
by: Day Of The Eagle | last post by:
Jeff_Relf wrote: > ...yet you don't even know what RegEx is. > I'm looking at the source code for mono's Regex implementation right now. You can download that source here ( use the class...
7
by: alphatan | last post by:
Is there relative source or document for this purpose? I've searched the index of "Mastering Regular Expression", but cannot get the useful information for C. Thanks in advanced. -- Learning...
7
by: bill tie | last post by:
I'd appreciate it if you could advise. 1. How do I replace "\" (backslash) with anything? 2. Suppose I want to replace (a) every occurrence of characters "a", "b", "c", "d" with "x", (b)...
5
by: Kofi | last post by:
Any takers? Got a string of DNA as an input sequence GGATGGATG, apply the simple regex "GGATG" as in Regex r = new Regex("GGATG", (RegexOptions.Compiled)); MatchCollection matches =...
8
by: Bob | last post by:
I need to create a Regex to extract all strings (including quotations) from a C# or C++ source file. After being unsuccessful myself, I found this sample on the internet: ...
7
by: CB | last post by:
Trying to match the entire following object literal code using a RegEx. var Punctuators = { '{' : 'LeftCurly', '}' : 'RightCurly' } Variations on the idea of using /var.*{.*}/ of course stops...
0
by: Tidane | last post by:
Visual Basic.NET Framework 2.0 I've created a program to parse out text as the program recieved it and use Regex matching to decide what should be done. My problem is that the text is matching when...
4
by: pedrito | last post by:
I have a regex question and it never occurred to me to ask here, until I saw Jesse Houwing's quick response to Phil for his Regex question. I have some filenames that I'm trying to parse out of...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
0
BarryA
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...
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
marktang
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,...
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
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.