473,395 Members | 1,936 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,395 software developers and data experts.

RegExp: Backreference in ClassRange

Consider the following RegExp:

/[\1]/
ECMA-262 says:

<quote (with slight modification of non-ASCII character)>

15.10.2.11 DecimalEscape

The production DecimalEscape :: DecimalIntegerLiteral
[lookahead != DecimalDigit] evaluates as follows.

1. Let i be the MV of DecimalIntegerLiteral.
2. If i is zero, return the EscapeValue consisting of a <NUL>
character (Unicode value 0000).
3. Return the EscapeValue consisting of the integer i.

...

15.10.2.19 ClassEscape

The production ClassEscape :: DecimalEscape evaluates as follows:

1. Evaluate DecimalEscape to obtain an EscapeValue E.
2. If E is not a character then throw a SyntaxError exception.
3. Let ch be E's character.
4. Return the one-element CharSet containing the character ch.

</>
a) The DecimalEscape returns a character for "\0", and an
integer for decimals 1-9, which means that the ClassEscape
should throw an exception at step 2. Is this reading
correct?

Opera does not throw an exception.

Test case:
<http://home.swipnet.se/sigsegv/opera/bugs/js-re-class-backref.html>
Result:
<http://home.swipnet.se/sigsegv/opera/bugs/js-re-class-backref.png>
b) Interestingly, the RegExp:

/[\101-\105]+/.exec ("ABCDefgh")

results in:

* "ABCD" in FireFox 1.0.3 (octal conversion), and
* "efgh" in Opera 8.01 (decimal conversion).

An exception ought be thrown as in a), oughtn't it?
--n
Jul 23 '05 #1
1 2357
On 22/06/2005 20:15, Nisse Engström wrote:
Consider the following RegExp:

/[\1]/

[...] the ClassEscape should throw an exception [...]


With a strict implementation of ECMA-262, yes it should. However, I
doubt that any browser implementation is strict - it would break the Web.

Notice in section 2 - Conformance:

"A conforming implementation of ECMAScript is permitted to support
program and regular expression syntax not described in this
specification."

[snip]

Mike

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
Jul 23 '05 #2

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

Similar topics

6
by: Brian Richmond | last post by:
I'm trying to use a regular expression to match a hidden html tag and replace it with the results of a mysql query. The query is based off a part of the hidden tag. For example: The article...
10
by: Anand Pillai | last post by:
To search a word in a group of words, say a paragraph or a web page, would a string search or a regexp search be faster? The string search would of course be, if str.find(substr) != -1:...
5
by: Lukas Holcik | last post by:
Hi everyone! How can I simply search text for regexps (lets say <a href="(.*?)">(.*?)</a>) and save all URLs(1) and link contents(2) in a dictionary { name : URL}? In a single pass if it could....
0
by: Chris Croughton | last post by:
I'm trying to use the EXSLT regexp package from http://www.exslt.org/regexp/functions/match/index.html (specifically the match function) with the libxml xltproc (which supports EXSLT), but...
0
by: rodrigo | last post by:
This is the source text I am working on. 3593 blue $15.95 3944 yellow 8.10 4001 brown $9.75 Basically I want to extract each part separately like this part 1 3593
4
by: Jon Maz | last post by:
Hi All, I want to strip the accents off characters in a string so that, for example, the (Spanish) word "práctico" comes out as "practico" - but ignoring case, so that "PRÁCTICO" comes out as...
7
by: iannorton | last post by:
Hi, I'm trying to write a RegExp that will return search an array and return the closest 10 matches, for example, if i entered "Hel" and my array contained "Hello", "Hell", it would return Hello...
2
by: Schüle Daniel | last post by:
X-Enigmail-Version: 0.76.5.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Hello @all, >>> p =...
2
by: brad | last post by:
Hello all, I'm new to javascript--not too new to a few other programming languages--and I need your help deciphering the Regexp in the following string. Regular expresions are hard enough in...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: 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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.