Solved

Backslash in javascript regexp

Posted on 2008-10-17
5
169 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
Comment Utility
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
Comment Utility
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
Comment Utility
Did that help?  Where you able to create the backslash.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Learn to move / copy / export exchange contacts to iPhone without using any software. Also see the issues in configuration of exchange with iPhone to migrate contacts.
Find out what Office 365 Transport Rules are, how they work and their limitations managing Office 365 signatures.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

771 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

16 Experts available now in Live!

Get 1:1 Help Now