Hello! Does anyone know a good archive for all different types of
Regular expressions?
I am 90% done a website and the last 10% is putting validation on over
100 fields. They range from needing to:
- verify valid email (I already have this reg exp)
- verify hexadecimal number
- verify name would be valid as a filename
- phone number
Etc., etc. I figure ALL of these things have been done, so why
re-invent the wheel. But surfing the Net looking for Regular
Expressions is leading me to a bunch of tutorial sites and rinky dink
Javascript sites.
Thanks!
Holden 9 1930 co***********@h otmail.com (Holden Caulfield) writes: Hello! Does anyone know a good archive for all different types of Regular expressions?
There are some references at the bottom of FAQ 4.16. http://jibbering.com/faq/
The canonical reference is "Mastering regular expressions" by
Jeffrey E. F. Friedl. O'Reilly, 2nd edition 2002.
--
Chris Jeris cj****@oinvzer. net Apply (1 6 2 4)(3 7) to domain to reply.
JRS: In article <6d************ **************@ posting.google. com>, seen
in news:comp.lang. javascript, Holden Caulfield
<co***********@ hotmail.com> posted at Wed, 21 Jan 2004 14:07:55 :- Hello! Does anyone know a good archive for all different types of Regular expressions?
I am 90% done a website and the last 10% is putting validation on over 100 fields. They range from needing to:
- verify valid email (I already have this reg exp)
Task cannot be done. Some classes of invalidity can be detected. A
good checker will check the whole of a mail header line according to
applicable RFCs, not just look for something like fred at hitmule dot
con.
- verify hexadecimal number
Trivial, but you must remember that different systems use different
indicators for Hex. I am familiar with three, and aware of another,
and expect that there are more.
- verify name would be valid as a filename
Who knows what may be valid as a filename? not all file systems run DOS
/ Windows / Unix.
- phone number
Impracticable, except in limited milieux. Have you understood ITU
E.123, for example?
Etc., etc. I figure ALL of these things have been done, so why re-invent the wheel. But surfing the Net looking for Regular Expressions is leading me to a bunch of tutorial sites and rinky dink Javascript sites.
There is in addition the question of how best to make use of RegExps in
quantity without repetitive coding.
<URL:http://www.merlyn.demo n.co.uk/js-valid.htm> refers.
BTW, do you come from a country where International Standards are
generally known and respected by the technical community? If not, you
might do better to explicitly address only that limited audience, and
leave the wider task to those in a better position to appreciate it.
Unless you can be absolutely sure of accepting for a given field all
forms that are valid or may become valid within the like of the code,
you need to make the checking advisory only.
N.B. Dates can be fully validated; but only if the input is not free-
format. Consider 13/09/1752 - is it valid? 1700-02-29?
--
© John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 IE 4 ©
<URL:http://jibbering.com/faq/> Jim Ley's FAQ for news:comp.lang. javascript
<URL:http://www.merlyn.demo n.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demo n.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
Thanks, but... There are some references at the bottom of FAQ 4.16. http://jibbering.com/faq/
1 of the 2 links is a 404, and the working link (to a doc I already
have) is an introductory lesson on making my own.
I do not want to reinvent the wheel.
Does no one know of a good source for ready-to-go Regular
Expressions??
Thanks,
H.C. co***********@h otmail.com (Holden Caulfield) writes: Does no one know of a good source for ready-to-go Regular Expressions??
I personally wouldn't use such a source any more.
I posted what I thought was a good expression for syntactically
correct email addresses. It was even taken from a pretty respectable
source (Danny Goodman's "Dynamic HTML: The Definitive Reference").
Lasse (and some others? I don't remember) pointed out quite correctly
that it was a long way from accepting all email addresses valid
according to RFC 2822. I didn't read the spec. I guess Goodman
didn't either.
The effort you exert to "reinvent the wheel" is likely to be
comparable to the effort you exert to try two or three dubious
candidates from various sources, dissect them symbol-by-symbol and
test boundary cases to verify that they meet your needs. If you've
defined your needs precisely enough that you can do that, you know
almost everything you need to know to write the expression yourself
anyway.
All that being said, I suppose that /[0-9A-Fa-f]*/ can be relied upon
to match a string of zero or more hexadecimal digits, _if_ your
definition of "hexadecima l digit" is "0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A,
B, C, D, E, F, a, b, c, d, e, or f". Whether that definition is
satisfactory depends on your needs. In India, for example, the
customary decimal numerals are different and have different code
points in Unicode; I don't know what the customary hexadecimal
numerals are.
The point, which I am belaboring, is that you must know _exactly_ the
class of strings you intend to accept, and then you have more or less
written the expression already.
And, as other people say about once a day on this group, you cannot
rely on client-side form validation, so you have to duplicate your
expressions (possibly in a language with slightly different RE
semantics) server-side.
--
Chris Jeris cj****@oinvzer. net Apply (1 6 2 4)(3 7) to domain to reply.
Christopher Jeris <cj****@oinvzer .net> writes: All that being said, I suppose that /[0-9A-Fa-f]*/ can be relied upon to match a string of zero or more hexadecimal digits,
Actually, it matches all strings whatsoever. You forgot to anchor it as
/^[0-9A-Fa-f]$/. Your regular expression matches a string if it contains
a substring that is zero or more hexadecimal digits. All strings contain
a substring of length zero.
I have made that mistake far to often myself, and would have preferred
if matches always had to be against the entire string. Then you could
add .* before and after if you wanted it. But, alas, that was not the
way they did it, probably for historical reasons.
The point, which I am belaboring, is that you must know _exactly_ the class of strings you intend to accept, and then you have more or less written the expression already.
I concur.
/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>
'Faith without judgement merely degrades the spirit divine.'
Lasse Reichstein Nielsen <lr*@hotpop.com > writes: Christopher Jeris <cj****@oinvzer .net> writes: All that being said, I suppose that /[0-9A-Fa-f]*/ can be relied upon to match a string of zero or more hexadecimal digits, Actually, it matches all strings whatsoever. You forgot to anchor it as /^[0-9A-Fa-f]*$/. Your regular expression matches a string if it contains a substring that is zero or more hexadecimal digits. All strings contain a substring of length zero.
Well, it depends on what you mean by 'match', right?
If what you want is a test "does the input string belong to the language
generated by this regular expression", then of course you're right.
If you want "give the initial segment of the input string matched by
this expression", then the anchors aren't appropriate, correct?
I wish I could say that I was thinking about this when I wrote my post,
but in fact you've merely caught another of my novice mistakes posted
to the group. Maybe I should shut up. :)
--
Chris Jeris cj****@oinvzer. net Apply (1 6 2 4)(3 7) to domain to reply.
JRS: In article <xi************ *@hsph.harvard. edu>, seen in
news:comp.lang. javascript, Christopher Jeris <cj****@oinvzer .net> posted
at Thu, 22 Jan 2004 17:49:50 :- And, as other people say about once a day on this group, you cannot rely on client-side form validation, so you have to duplicate your expressions (possibly in a language with slightly different RE semantics) server-side.
Not invariably.
NONE of my Web pages submit anything, and several of those not called
js-*.htm contain inputs which might be validated.
One with a university address should not be assuming that the "business-
and-customer" model applies everywhere.
In these pages, on the whole I tend to consider it sufficient if all
input either is valid or causes manifest nonsense output (such as a date
with the numeric fields all the string "NaN").
--
© John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 IE 4 ©
<URL:http://jibbering.com/faq/> Jim Ley's FAQ for news:comp.lang. javascript
<URL:http://www.merlyn.demo n.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demo n.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
Thanks Usman!
That´s what I am looking for, links to ready-made expressions! I can
sort through these and pick out the one best suited to my needs...
Thank you,
H.C. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Kenneth McDonald |
last post by:
I'm working on the 0.8 release of my 'rex' module, and would appreciate
feedback, suggestions, and criticism as I work towards finalizing the
API and feature sets. rex is a module intended to make regular expressions
easier to create and use (and in my experience as a regular expression
user, it makes them MUCH easier to create and use.)
I'm still working on formal documentation, and in any case, such
documentation isn't necessarily the...
|
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
testMyColumn{1, 100}Test
Basically I want the regular expression to add the word test infront of the
|
by: Neri |
last post by:
Some document processing program I write has to deal with documents
that have headers and footers that are unnecessary for the main
processing part. Therefore, I'm using a regular expression to go over
each document, find out if it contains a header and/or a footer and
extract only the main content part.
The headers and the footers have no specific format and I have to
detect and remove them using a list of strings that may appear as...
|
by: Dimitris Georgakopuolos |
last post by:
Hello,
I have a text file that I load up to a string. The text includes
certain expression like {firstName} or {userName} that I want to match
and then replace with a new expression. However, I want to use the
text included within the brackets to do a lookup so that I can replace
the expression with the new text.
For example:
|
by: James D. Marshall |
last post by:
The issue at hand, I believe is my comprehension of using regular
expression, specially to assist in replacing the expression with other text.
using regular expression (\s*) my understanding is that this will one or
more occurrences to replace all the white space between with a comma.
This search
ElseIf InStr(1, indivline, "$") Then
insert a replace statement that uses the regular expression to find and
replace all the white space...
| |
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 a "replace" it makes a new copy of string and I want to avoid
that. My question here is if there is a way to pass either a memory
stream or array of "find", "replace" expressions or any other way to
avoid multiple copies of a string.
Any help will be highly appreciated
|
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 (CONDUCTION
DEFECT) 37.33/2 HEART (CONDUCTION DEFECT) WITH
CATHETER 37.34/2 " the expression is "HEART (CONDUCTION DEFECT)". How
do I gain access to the expression (not the matches) at runtime?
Thanks,
Mike
|
by: Allan Ebdrup |
last post by:
I have a dynamic list of regular expressions, the expressions don't change
very often but they can change. And I have a single string that I want to
match the regular expressions against and find the first regular expression
that matches the string.
I've gor the regular expressions ordered so that the highest priority is
first (if two or more regular expressions match the string I want the first
one returned)
The code that does this has...
|
by: NvrBst |
last post by:
I want to use the .replace() method with the regular expression /^ %VAR
% =,($|&)/. The following DOESN'T replace the "^default.aspx=,($|&)"
regular expression with "":
---------------------------------
myStringVar = myStringVar.replace("^" + iName + "=,($|&)", "");
---------------------------------
The following DOES replace it though:
---------------------------------
var match = myStringVar.match("^" + iName + "=,($|&)");
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |