Solved

regular expression handling apostrophe

Posted on 2014-04-15
7
289 Views
Last Modified: 2014-06-01
Hi Experts,

I went to the following link and tried to modify the rgeular expression so it accepts the apostrophe but couldnt,



I need your help to solve this problem.

Please post the working solution.

Thanks
0
Comment
Question by:bachra04
7 Comments
 
LVL 2

Author Comment

by:bachra04
ID: 40003136
Sorry here is the link:

http://jsfiddle.net/CsQn7/98/
0
 
LVL 35

Expert Comment

by:Dan Craciun
ID: 40003149
var r = new RegExp('^[\'a-zA-Z0-9\\*]\\\\]\\*$');

HTH,
Dan
0
 
LVL 2

Author Comment

by:bachra04
ID: 40004113
I don't know why right now the test is giving me false for any value I enter.

http://jsfiddle.net/CsQn7/98/
0
 
LVL 35

Expert Comment

by:Terry Woods
ID: 40005196
It gives true for the value:
f\]*

Open in new window

Did you want to match a literal backslash character?
0
 
LVL 9

Accepted Solution

by:
Derek Jensen earned 500 total points
ID: 40007049
http://jsfiddle.net/CsQn7/98/ returns true for an apostrophe using this line:

var r = new RegExp("^['a-zA-Z0-9\*]\\\]\*$");

Open in new window

0

Featured Post

How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
JavaScript has plenty of pieces of code people often just copy/paste from somewhere but never quite fully understand. Self-Executing functions are just one good example that I'll try to demystify here.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question