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

How do we use regular expressions in JavaScript?

129 100+
Hello friends,
I need answer to the question, How do we use regular expressions in javascript? Is there any manual or website to refer about this topic. Please help me friends
Dec 14 '07 #1
8 4039
acoder
16,027 Expert Mod 8TB
I've changed the thread title to better describe the question.

See this link.
Dec 14 '07 #2
sasimca007
129 100+
Hello friends,
I want to know how to work with regular expressions in javascript. I am doing a regular expression below:

var patt = /[\efijklmnpqrstuvwxyz013456789\.\<\>\?\/\:\;\'\"\{\}\[\]\~\!\@\#\$\%\^\&\*\(\)\_\-\+\=\`\s]/gi;

It is working on normal html program but it is not matching in modperl. So, i want to match the above pattern. Please help me
Apr 22 '08 #3
acoder
16,027 Expert Mod 8TB
Do you mean the regular expression works in an HTML page, but not on a Perl page?
Apr 22 '08 #4
sasimca007
129 100+
Do you mean the regular expression works in an HTML page, but not on a Perl page?
Yes my friend. That regexp is not working in modperl program
Apr 23 '08 #5
acoder
16,027 Expert Mod 8TB
Show the rest of the code. How is the code/function called? What is it trying to test?
Apr 23 '08 #6
sasimca007
129 100+
Show the rest of the code. How is the code/function called? What is it trying to test?
Expand|Select|Wrap|Line Numbers
  1. function func(obj)
  2. {
  3.     var txt = obj.value;
  4.     var patt = /[\efijklmnpqrstuvwxyz013456789\.\<\>\?\/\:\;\'\"\{\}\[\]\~\!\@\#\$\%\^\&\*\(\)\_\-\+\=\`\s]/gi;
  5.     if(!(txt.match(patt)))
  6.     {    obj.value = txt.toUpperCase();    }
  7.     else
  8.     {       alert("Wrong letter");       }
  9. }
  10.  
[HTML]<td align=center><input type='text' name='$code-$testdate' id='reg_box_parent' value='$shcode' size=3 onkeyup='func(this)' maxlength=8>[/HTML]
Apr 23 '08 #7
acoder
16,027 Expert Mod 8TB
As a full member now, you should know that we expect your code to be posted in [code] tags (See How to Ask a Question).

This makes it easier for our Experts to read and understand it. Failing to do so creates extra work for the moderators, thus wasting resources, otherwise available to answer the members' questions.

Please use the tags in future.

MODERATOR.
Apr 23 '08 #8
acoder
16,027 Expert Mod 8TB
So, it can't match any of those letters, symbols/characters, etc.

How about writing a reg exp for the allowed characters instead and matching those?
Apr 23 '08 #9

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

Similar topics

4
by: Befuddled | last post by:
I am writing a function to have its argument, HTML-containing string, return a DOM 1 Document Fragment, and so it seems the use of regular expressions (REs) is a natural. My problem is that the...
18
by: Q. John Chen | last post by:
I have Vidation Controls First One: Simple exluce certain special characters: say no a or b or c in the string: * Second One: I required date be entered in "MM/DD/YYYY" format: //+4 How...
5
by: Markus Innerebner | last post by:
Hello to everyone, Yesterday I tried long time to make a validation for a number format input field. As I am using Regex in Java I wrote following expression: String pattern =...
3
by: a | last post by:
I'm a newbie needing to use some Regular Expressions in PHP. Can I safely use the results of my tests using 'The Regex Coach' (http://www.weitz.de/regex-coach/index.html) Are the Regular...
20
chunk1978
by: chunk1978 | last post by:
hi everyone... i'm preparing to complete a validated form through client-side javascript with regular expressions... and yes the form will also be validated server-side as well... anyway, my regex...
20
by: Geoff Hill | last post by:
What's the way to go about learning Python's regular expressions? I feel like such an idiot - being so strong in a programming language but knowing nothing about RE.
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...
6
by: Jeff | last post by:
I always have trouble with javascript regexes... I want to parse apart a string and remember the matches and use them elswhere. Say I have: var test_string='one_two-three'; In perl I...
12
by: FAQEditor | last post by:
Anybody have any URL's to tutorials and/or references for Regular Expressions? The four I have so far are: http://docs.sun.com/source/816-6408-10/regexp.htm...
12
by: joey.powell | last post by:
Hello guys, I am primarily an asp.net programmer, but lately I've been doing some work with Apache, MySQL and PHP. Anyways, I have a question that I posted in the microsoft asp.net newsgroup....
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.