Solved

Backslash in javascript regexp

Posted on 2008-10-17
5
171 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 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Datepicker 3 229
Problem to run jar file 4 147
Jquery Tree Grid 7 209
Boostrap Select - Javascript Selectbox Question 3 146
There are many Password Managers (PM) out there to choose from. PM's can help with your password habits and routines, but they should not be a crutch you rely on too heavily. I also have an article for company/enterprise PM's.
: Microsoft Office Collaborate for free and online versions of Microsoft  Word, Excel, Powerpoint, OneNote, Onedrive , Email, Calendar etc. In short we can say that Microsoft office is a suite of servers, applications and services developed by  Micr…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

867 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now