JavaScript regular expression dot operator (any character) does not include newlines

RESOLVED INVALID

Status

()

--
major
RESOLVED INVALID
12 years ago
12 years ago

People

(Reporter: niels_h_jensen, Unassigned)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

(Reporter)

Description

12 years ago
User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.7) Gecko/20060910 MultiZilla/1.8.2.0i SeaMonkey/1.0.5
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.7) Gecko/20060910 MultiZilla/1.8.2.0i SeaMonkey/1.0.5

In a JavaScript regular expression the 'dot' (placeholder for any character) does NOT include newlines as it should.
Example (see attached demo):

The code '.replace(/1.*?4/g, 'x')' works fine in replacing '1234' with 'x' but fails for '12\n34'.

Substitutes for '.', e.g. '[\w\W]' or '[\s\S]' work correct.

Reproducible: Always




The bug is seen in SeaMonkey/1.0.5 and Firefox/1.5.0.2
(Reporter)

Comment 1

12 years ago
Created attachment 244521 [details]
testcase: JavaScript regular expression dot operator (any character) does not include newlines
(Reporter)

Comment 2

12 years ago
Oops, on re-reading the docs I see that this is the intended behaviour. Sorry. I don't really understand why this non-standard and counter-intuitive behaviour was implemented :-S
Status: UNCONFIRMED → RESOLVED
Last Resolved: 12 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.