Solved

Backslash in javascript regexp

Posted on 2008-10-17
5
180 Views
Last Modified: 2013-12-12
I need the following js regexp to also match back slashes \
var matchString = new RegExp("[a-zA-Z0-9&-/]");

What should I add?
0
Comment
Question by:susanBuck
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
5 Comments
 
LVL 9

Accepted Solution

by:
EZFrag earned 125 total points
ID: 22739480
Hi there,

All you hopefully need to to is add an escaped backslash:

var matchString = new RegExp("[a-zA-Z0-9&-/\\]");

Hope it helps ;)
EZFrag
0
 
LVL 3

Expert Comment

by:dawnna
ID: 32819997
This is for Python...

\section       Text string to be matched

\\section       Escaped backslash for re.compile

"\\\\section"       Escaped backslashes for a string literal

The regular expression \\ matches a single backslash. In JavaScript, this becomes re = /\\/ or re = new RegExp("\\\\").
0
 
LVL 3

Expert Comment

by:dawnna
ID: 32825931
Did that help?  Where you able to create the backslash.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

After seeing numerous questions for Dynamic Data Validation I notice that most have used Visual Basic to solve the problem. This suggestion is purely formula based and can be used in multiple rows.
This article explains the fundamentals of industrial networking which ultimately is the backbone network which is providing communications for process devices like robots and other not so interesting stuff.
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

623 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