Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Backslash in javascript regexp

Posted on 2008-10-17
5
Medium Priority
?
189 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
  • 2
5 Comments
 
LVL 9

Accepted Solution

by:
EZFrag earned 500 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

Technology Partners: 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

Microsoft Access has a limit of 255 columns in a single table; SQL Server allows tables with over 255 columns, but reading that data is not necessarily simple.  The final solution for this task involved creating a custom text parser and then reading…
The decision to migrate to the cloud is not a simple one—many factors, such a cost, ease of use, and ongoing maintenance come into play. The goal is always for cloud platforms to make storage and backups more seamless and effective. Here’s a look at…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …

927 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