473,382 Members | 1,710 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

for Ivo or expert in Character Escape w

den
var newstring = oldstring.replace( /[^\w_-]/g, '' );
in this example you use

w_- if I want other at characters a-zA-Z0-9 also the undersscore _ and -;
but inner w is there underscore _ , or is preferable however to rewrite it
outside for greater compatibility (particular version of javascripts,
browser, et cetera .. ?
Mar 10 '07 #1
2 1169
den wrote:
var newstring = oldstring.replace( /[^\w_-]/g, '' );
in this example you use

w_- if I want other at characters a-zA-Z0-9 also the undersscore _ and -;
but inner w is there underscore _ , or is preferable however to rewrite it
outside for greater compatibility (particular version of javascripts,
browser, et cetera .. ?
No, is fine on that line for me :). I'd bother on using a variable for the
regex only if it's rather long or needs to be changed/updated/modified during
the runtime.

Danny
Mar 11 '07 #2
Ivo
"Danny" wrote
den wrote:
>var newstring = oldstring.replace( /[^\w_-]/g, '' );
in this example you use

w_- if I want other at characters a-zA-Z0-9 also the undersscore _
and -;
but inner w is there underscore _ , or is preferable however to rewrite
it
outside for greater compatibility (particular version of javascripts,
browser, et cetera .. ?

No, is fine on that line for me :). I'd bother on using a variable for
the
regex only if it's rather long or needs to be changed/updated/modified
during
the runtime.
You 're right, den. The underscore character does not need to be explicitly
mentioned since the metacharacter \w covers it already. There was some
uncertainly in the past about this, but I am not aware now of any JS1.2
browser that fails here. Still, it does not do much harm in the expression.
And no, creating a variable regex is not necessary in this script.
hth
ivo
Mar 11 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Alden Streeter | last post by:
Here is the HTML that is being output by my asp page: <a href='Files/category/computers/bigimages/computers-sub-monitors.jpg' target='_blank' onMouseOver="window.status='Click for a larger image...
4
by: John Winterbottom | last post by:
Hi all Using SQL Server 2000 SP3 on WIn2K Pro with SP2. When I do this SELECT PATINDEX('%%', 'ABC]DEF') GO
5
by: Gary Mayor | last post by:
Hi, If I have the ' character within the javascript:pick command it doesn't work. Is there some sort of way of escaping these characters like in server side languages. function pick(symbol) {...
7
by: teachtiro | last post by:
Hi, 'C' says \ is the escape character to be used when characters are to be interpreted in an uncommon sense, e.g. \t usage in printf(), but for printing % through printf(), i have read that %%...
7
by: Steve | last post by:
string str ="\"C:\Program Files\Internet Explorer\iexplore.exe\" -nohome" How can I remove charcter to string str = ="C:\Program Files\Internet Explorer\iexplore.exe -nohome"
12
by: Jeff S | last post by:
In a VB.NET code behind module, I build a string for a link that points to a JavaScript function. The two lines of code below show what is relevant. PopupLink = "javascript:PopUpWindow(" &...
15
by: pkaeowic | last post by:
I am having a problem with the "escape" character \e. This code is in my Windows form KeyPress event. The compiler gives me "unrecognized escape sequence" even though this is documented in MSDN....
3
KevinADC
by: KevinADC | last post by:
Purpose The purpose of this article is to discuss the difference between characters inside a character class and outside a character class and some special characters inside a character class....
2
by: christopher taylor | last post by:
hello python-list! the other day, i was trying to match unicode character sequences that looked like this: \\uAD0X... my issue, is that the pattern i used was returning:
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.