473,699 Members | 2,680 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1925
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.
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.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.
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***********@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.
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/rasterTriangleD OM.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.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.
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
4172
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...
4
5153
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
4
3222
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...
11
5374
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:
3
3213
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...
7
3825
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
25
5151
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
1
4380
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...
1
3398
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 + "=,($|&)");
0
8686
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, 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...
0
9173
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, 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...
1
8911
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6533
isladogs
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...
0
5872
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4627
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3057
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2345
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2009
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.