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

Regular Expression Valhalla

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
Jul 20 '05 #1
9 1912
co***********@hotmail.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.
Jul 20 '05 #2
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.demon.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.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
Jul 20 '05 #3
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.
Jul 20 '05 #4
co***********@hotmail.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 "hexadecimal 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.
Jul 20 '05 #5
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/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #6


http://www.regexplib.com
thanks

usman shaheen

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #7
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.
Jul 20 '05 #8
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.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
Jul 20 '05 #9
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.
Jul 20 '05 #10

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

Similar topics

1
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...
4
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...
4
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...
11
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,...
3
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...
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 a "replace" it makes a new copy of string and I...
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 words, when I apply ^(.+)(?=\s*).*\1 to " HEART...
1
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...
1
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 "":...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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
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.