Closed
Bug 180957
Opened 22 years ago
Closed 18 years ago
unable to use regexp in install.js script
Categories
(Core Graveyard :: Installer: XPInstall Engine, defect)
Tracking
(Not tracked)
RESOLVED
INVALID
People
(Reporter: bugzilla, Assigned: dveditz)
Details
I have an install.js script inside a xpi package that have this js: var re = /(.*?)\.(\d+)$/; re.test("1.0.1.2002111900"); The script dies with the following: Error: can't convert Error to string Error: re.test is not a function Source File: Line: 10 isn't it possible to use regexp inside a js script in a xpi package?
Reporter | ||
Comment 1•22 years ago
|
||
while this works... weird! myProductRegVersion = "1.0.1.2002111900" var re = new String(myProductRegVersion); re.search(/(.*?)\.(\d+)$/);
Comment 2•22 years ago
|
||
> var re = /(.*?)\.(\d+)$/;
var re = "/(.*?)\.(\d+)$/";
will probably get you more mileage. And I agree with the error message.
re.test is not a function.
Henrik, are you trying to compare the used mozilla version? You can do that with this example: const NEED_MOZ_BUILD = 2002101708; if (buildID < NEED_MOZ_BUILD) foo else bar
Assignee | ||
Comment 4•22 years ago
|
||
comment 2: brush up on regular expressions. no quotes around regexp literals and RegExp objects most definitely have a test function.
Comment 5•22 years ago
|
||
-var re = /(.*?)\.(\d+)$/; +var re = /(.*)\.(\d+)$/; the '?' has nothing to act on.
Comment 6•18 years ago
|
||
Thanks Henrik, you saved my day :) The workaround is in fact: new RegExp("(.*?)\\.(\\d+)$") This one will has a test() method and everything. Somehow a regexp literal isn't a real regexp in install.js, just as a string literal isn't a real string. Creating them explicitely with the "new" operator works however.
Comment 7•18 years ago
|
||
Can anyone confirm that this bug is either bogus (as I suspect, in agreement with comment #5) or fixed?
Reporter | ||
Comment 8•18 years ago
|
||
not a bug
Status: NEW → RESOLVED
Closed: 18 years ago
Resolution: --- → INVALID
Updated•9 years ago
|
Product: Core → Core Graveyard
You need to log in
before you can comment on or make changes to this bug.
Description
•