Closed Bug 359326 Opened 18 years ago Closed 18 years ago

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

Categories

(Firefox :: General, defect)

x86
Windows XP
defect
Not set
major

Tracking

()

RESOLVED INVALID

People

(Reporter: niels_h_jensen, Unassigned)

Details

Attachments

(1 file)

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
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
Closed: 18 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: