473,396 Members | 2,020 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,396 software developers and data experts.

[JavaScript] Problem with Regular Expression

263 100+
[Javascript] Problem with Regular Expression

Hi all,

First of all I must say that I am a newbie when it comes to javascript language.
Here is my problem.

I need validate in `myForm` this string:
Expand|Select|Wrap|Line Numbers
  1. 09 - AB800
And try this Regular Expression:
Expand|Select|Wrap|Line Numbers
  1. if (!myForm.Folder.value.match("/^0[0-9] \- [a-z0-9]{5,20}$/i", "")) {
  2.      window.alert('Not valid.');
  3.      myForm.Folder.focus();
  4.      myForm.Folder.select();
  5.      return false;
  6.      }
  7.  
But the correct string:
Expand|Select|Wrap|Line Numbers
  1. 09 - AB800
is not validate. Why?

I need also optional add this other string:
Expand|Select|Wrap|Line Numbers
  1. 09 - AB800/test
when the string part `/test` is not required.

Can you explain any one or any sample code related this...

Your help would be very appreciated.
thanks for your time and hints.

Thanks in advance.
Cheers
May 25 '12 #1

✓ answered by Dormilich

the main problem is that .match() expects a RegExp object to be given, not two strings.

4 1639
Dormilich
8,658 Expert Mod 8TB
the main problem is that .match() expects a RegExp object to be given, not two strings.
May 25 '12 #2
viki1967
263 100+
Hello.
I'd appreciate your help so very much.

What is your suggestion?
May 25 '12 #3
Dormilich
8,658 Expert Mod 8TB
pass a RegExp object.
May 25 '12 #4
viki1967
263 100+
Thanks you very much for your help
I'm really happy for your quickly answer.
Good bye
May 25 '12 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: paulsmith5 | last post by:
Hi, I have the following regular expression to validate a date-time field in European or d/m/y h:m:s format. ...
5
by: Bradley Plett | last post by:
I'm hopeless at regular expressions (I just don't use them often enough to gain/maintain knowledge), but I need one now and am looking for help. I need to parse through a document to find a URL,...
3
by: Lisa Bogart | last post by:
I am trying to take a string and parse it out into multiple strings based on a pattern but am stuck and am hoping someone can give me a clue. My pattern looks like so: sMatch =...
1
by: paulsmith5 | last post by:
Hi, I'm developing a web app and I want to validate a users input on a form. I need a regular expression to validate a string which must begin with a letter (i.e. A-Z or a-z) and must have 5...
1
by: vtxr1300 | last post by:
I'm having a problem with a regular expression in conjunction with the regular expression validator. I am trying to make sure that when a user browses for a file to upload, it ends in gif, jpeg or...
4
by: carlos | last post by:
I am working on a regular expression validation for my search page. What I have so far works for most cases, but I would like to fine tune it some. I am new to regular expressions, and I do not...
2
by: Joey | last post by:
Hello guys, I'm trying to learn about regular expressions. I need to be able to use an RE that can evaluate for STRINGS (or specific sequences of characters), not just occurances of characters....
9
by: Kirk | last post by:
Hi All, the following regular expression matching seems to enter in a infinite loop: ################ import re text = ' MSX INTERNATIONAL HOLDINGS ITALIA srl (di seguito MSX ITALIA) una '...
2
by: Sami | last post by:
How can I get the inner content of a tag with regular expression I couldn't the the opening and closing tags to match properly Input "fjkdjfkdj <div>sadfdf dfdf...
0
by: elenabul | last post by:
Edit DetailsView with regular expression validation Hi, I have a problem using the regular expression validation. In a detailed view I fill out a form to create record for an Employee. I have...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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...
0
agi2029
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,...

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.