I need to create a regular expression for a date field that works only
in the following format MM/DD/YYYY with the / in the format. No other
format can be inputted into the field. I need 2 numbers for MM 2
Numbers for DD and 4 numbers for YYYY. If the users enter 1 number for
month, 1 for day he should get an alert. Thanks.
I have this code and thought it was working but it is not. Any help
would be great. Thanks
Code:
var RegExPattern = /(\d{1,2})\W(\d{ 1,2})\W(\d{4})/; 6 1878
MrHelpMe <cl********@hot mail.comwrote:
>I need to create a regular expression for a date field that works only in the following format MM/DD/YYYY with the / in the format. No other format can be inputted into the field. I need 2 numbers for MM 2 Numbers for DD and 4 numbers for YYYY. If the users enter 1 number for month, 1 for day he should get an alert. Thanks.
I have this code and thought it was working but it is not. Any help would be great. Thanks
Code: var RegExPattern = /(\d{1,2})\W(\d{ 1,2})\W(\d{4})/;
The {1,2} elements tell it to accept one or two of the preceding
element. You say you want only two digits. I'd do something like this:
var RegExPattern = !\d{2})/\d{2})/\d{4}!
Using ! to delimit the RE instead of /, since you have slashes within
the RE.
--
Tim Slattery
MS MVP(DTS) Sl********@bls. gov http://members.cox.net/slatteryt
Tim Slattery wrote on 15 mei 2007 in
microsoft.publi c.inetserver.as p.general:
>>var RegExPattern = /(\d{1,2})\W(\d{ 1,2})\W(\d{4})/;
The {1,2} elements tell it to accept one or two of the preceding
element. You say you want only two digits. I'd do something like this:
var RegExPattern = !\d{2})/\d{2})/\d{4}!
Using ! to delimit the RE instead of /, since you have slashes within
the RE.
No, that !! is not part of j[ava]script regex
and those strange leftover )s?
Try:
if (/^\d{2}\/\d{2}\/\d{4}$/.test(t)) .....
or
if (/^(\d\d\/\){2}\d{4}$/.test(t)) .....
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
"Evertjan." <ex************ **@interxnl.net wrote:
>No, that !! is not part of j[ava]script regex and those strange leftover )s?
OOP didn't specify what language, this being an ASP group, I assumed
VBScript. Maybe the trailing semicolon should have meant something.
I looked at the MSDN documentation for REs, and didn't see anything
about delimiting them. They use the same example over and over, which
is a SUB getting an argument and simply using that argument for a
delimiter. No discussion of enclosing the pattern in quotes or using
slashes that I could find.
I did wonder about alternate delimiters. That works in Perl and other
Unix-like contexts, but I guess not here. IMHO, it would simplify some
things if it did.
The leftover parens were a mistake.
--
Tim Slattery
MS MVP(DTS) Sl********@bls. gov http://members.cox.net/slatteryt
On May 16, 9:22 am, Tim Slattery <Slatter...@bls .govwrote:
"Evertjan." <exjxw.hannivo. ..@interxnl.net wrote:
No, that !! is not part of j[ava]script regex
and those strange leftover )s?
OOP didn't specify what language, this being an ASP group, I assumed
VBScript. Maybe the trailing semicolon should have meant something.
I looked at the MSDN documentation for REs, and didn't see anything
about delimiting them. They use the same example over and over, which
is a SUB getting an argument and simply using that argument for a
delimiter. No discussion of enclosing the pattern in quotes or using
slashes that I could find.
I did wonder about alternate delimiters. That works in Perl and other
Unix-like contexts, but I guess not here. IMHO, it would simplify some
things if it did.
The leftover parens were a mistake.
--
Tim Slattery
MS MVP(DTS)
Slatter...@bls. govhttp://members.cox.net/slatteryt
Hello again everyone and thanks for the replies. Evertjan, I tried
what you recommended and received errors saying t was undefined.
However, after looking at this again I did manage to get this to
work. I expanded on my reg expressions and came up with the
following. If anyone see's anything wrong with this that I may have
overlooked please let me know.
/(\d{2})\W(\d{1, 2})\W(\d{4})/
Thanks again.
MrHelpMe wrote on 16 mei 2007 in microsoft.publi c.inetserver.as p.general:
Hello again everyone and thanks for the replies. Evertjan, I tried
what you recommended and received errors saying t was undefined.
However, after looking at this again I did manage to get this to
work. I expanded on my reg expressions and came up with the
following. If anyone see's anything wrong with this that I may have
overlooked please let me know.
/(\d{2})\W(\d{1, 2})\W(\d{4})/
It is wrong
1- if you specified the second number to have two characters
{2} in stead of {1,2}
try:
/(\d{2})\W(\d{2} )\W(\d{4})/
2- if you specify not to have unneccesaty characters in the regex:
no need to use ()
try:
/\d{2}\W\d{2}\W\ d{4}/
3- if you want only / as a delimiter
just escape the / by \/
try:
/\d{2}\/\d{2}\/\d{4}/
or:
/(\d\d\/\){2}\/\d{4}/
4- and because now the string 'qwert00/00/0000 asdfg'
will test true, you will have to insert start ^ and end $ markers:
try:
/^(\d\d\/\){2}\/\d{4}$/
=== As you specified jscript in this Asp NG
>>Code: var RegExPattern = /(\d{1,2})\W(\d{ 1,2})\W(\d{4})/;
by using var and ;
I suggest you use:
if ( /^(\d\d\/\){2}\/\d{4}$/.test(str) ) doWhatYouWantIf True();
=== I suggest you use international valid date strings like
yyyy-mm-dd or yyyy/mm/dd
=== But if you want only real dates to test true,
look in the archive of comp.lang.javas cript
for instance here [but all over that NG]:
<http://tinyurl.com/2hj4zw>
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Tim Slattery wrote on 16 mei 2007 in
microsoft.publi c.inetserver.as p.general:
"Evertjan." <ex************ **@interxnl.net wrote:
>>No, that !! is not part of j[ava]script regex and those strange leftover )s?
OOP didn't specify what language, this being an ASP group, I assumed
VBScript. Maybe the trailing semicolon should have meant something.
MrHelpMe wrote on 15 mei 2007 in microsoft.publi c.inetserver.as p.general:
Code:
var RegExPattern = /(\d{1,2})\W(\d{ 1,2})\W(\d{4})/;
The giveaway was the "var" plus that in this ASP NG I would primarily
expect vbscript or jscript.
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress) 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: Brian Kitt |
last post by:
I have a process where I do some minimal reformating on a TAB delimited
document to prepare for DTS load. This process has been running fine, but I
recently made a change. I have a Full Text index on one column, and
punctuation in the column was causing some problems down the line. This
column is used only for full text indexing, and otherwise ignored. I decided
to use the following regular expression to remove all punctuation (actually...
|
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: kieran |
last post by:
Hi,
I am using Visual Studio 2005 and am trying to use a Regular Expression
Validator control.
I have a drop down list which contains various names, the first one is
"Please Select". I want the user to have to select a name other than
'Please Select'.
I am thinking maybe the Regular Expression Validator is the best move
| |
by: Lucky |
last post by:
hi guys,
i'm practising regular expression. i've got one string and i want it to
split in groups.
i was trying to make one regular expression but i didn't successed.
please help me guys.
i'm using .NET 2.0's Regular expression class.
here is the string.
|
by: Zach |
last post by:
Hello,
Please forgive if this is not the most appropriate newsgroup for this
question. Unfortunately I didn't find a newsgroup specific to regular
expressions.
I have the following regular expression.
^(.+?) uses (?!a spoon)\.$
|
by: Mike9900 |
last post by:
Hello,
I need a regular expression to match a currency with its symbol, for example
Pound66.99 must return 66.99 or Pound(66.99) or Pound-66.99 or -66.99Pound
return -66.99 or any other combination return the decimal number.
I have created a regular expression, but it seems that it does not work if
the number is Pound66.99 but it works if the sign is after the number:
public static Decimal ConvertToDecimal(String str)
|
by: sunil |
last post by:
Hi,
Am writing one C program for one of my module and facing one problem
with the regular expression functions provided by the library libgen.h
in solaris.
In this library we are having two functions to deal with
the regular expressions
char *regcmp(const char *string1, /* char *string2 */ ,
|
by: =?Utf-8?B?VEo=?= |
last post by:
Hi,
I want to know how Regular Expression can be used in this situation.
I want to replace some string in specific condition..
The condition is to replace string only if the string is NOT inside of tag.
For example,
<Test id='wow'>wow</Test>
I want to replace the wow with great...So output will be
<Test id='wow'>great</Test>
|
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: 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,...
|
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: 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();...
|
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: 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
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |