AJAX Forums

Regualr Expression in Javascript

This is a discussion on Regualr Expression in Javascript within the JavaScript forums, part of the Beginners AJAX category; Hello All, This is the first time I am posting question in forum , if any mistakes found please forgive me. My question is, Regarding How to write a Regular Expression ...


Go Back   AJAX Forums > Beginners AJAX > JavaScript

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
Old 11-17-2007, 06:04 AM   #1 (permalink)
Junior Member
 
Join Date: Nov 2007
Posts: 1
Rep Power: 0 skayeesha is on a distinguished road
Question Regualr Expression in Javascript

Hello All,

This is the first time I am posting question in forum , if any mistakes found please forgive me.

My question is,

Regarding How to write a Regular Expression in javascript for my problem..

if i give expressions as

c1+c24
c1+c12+c3
(c1+c12)
(c10+c2+c33)
(c1+c2)+(c1+c4)
c1&&c2
c3||c2&&c6
c2<=c4
c1>=c12
c4>c23
c4<c24
c4==c3==c1


have to return " true " value


otherwise if i give expressions as ,

c1++c2
c1++c2+c3
c1+c2++c3
c1++c2++c3
(c1+c2)++
c1++
(c1++c2)
(c1+c2)+(c14++c6)
(c1++c2)++(c5++c7)
c1&&&&c2
c1||||||c3&&&&c6
c2<=<=<=c4
c1>=>=c12
c4>>>c23
c4<<c24
c4=====c3=====c1
(c1+c2)<=<=(c14++c6)
(c1++c2)&&&&(c5++c7)



hav to return " false " value


What I mean to say is if I take any operator (i.e., +,-,/*.&&,||,<,<=,>,>=,==) more than one same operator like ++,+++ etc., with or without paranthesis ,that regular expression have to retrun " false " value. Otherwise it have to
return " true " value.


Now i am using the below regular expression,but for some expressions only this is working,


function isValidExpr(expr) {
return /^([-+]{2})?(([+-]?c\d+)|([+-]?c\d+)([-+*\/]([+-]?c\d+))+|\(([+-]?c\d+)([-+*\/]([+-]?c\d+))+\))([-+]{2})?([-+*\/]([-+]{2})?(([+-]?c\d+)|([+-]?c\d+)([-+*\/]([+-]?c\d+))+|\(([+-]?c\d+)([-+*\/]([+-]?c\d+))+\))([-+]{2})?)+$/i.test(expr);
}


But not for all expressions...



Please solve my problem as soon as possible,in my office i asked so many people but no one worked on this regular expression..

I am expecting you all people can answer my question...

Waiting for all your replies...


WELL ONE MORE THINGS i ASKED SO MANY PEOPLE THEY RSAID TRY OTHER THAN REGULAR EXPRESSION.O TRIED BUT I AM NOT GETTING EXACT SOLUTION FOR MY PROBLEM


Regards,
Ayeesha Shaik
skayeesha is offline   Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes



All times are GMT -4. The time now is 04:38 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0 RC5
Copyright ©2006 - 2008, AJAXwith.com