Solved

Backslash in javascript regexp

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
fetching data 4 196
AJAX post submit actions 6 264
Javascript simple function doesn't work 6 116
CRM 2011 Cascade Quote to Order and Order to Invoice 4 78
The business world is becoming increasingly integrated with tech. It’s not just for a select few anymore — but what about if you have a small business? It may be easier than you think to integrate technology into your small business, and it’s likely…
This article explains the steps required to use the default Photos screensaver to display branding/corporate images
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

792 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