Closed Bug 180957 Opened 23 years ago Closed 19 years ago

unable to use regexp in install.js script

Categories

(Core Graveyard :: Installer: XPInstall Engine, defect)

x86
Windows 2000
defect
Not set
normal

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?
while this works... weird! myProductRegVersion = "1.0.1.2002111900" var re = new String(myProductRegVersion); re.search(/(.*?)\.(\d+)$/);
> 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
comment 2: brush up on regular expressions. no quotes around regexp literals and RegExp objects most definitely have a test function.
-var re = /(.*?)\.(\d+)$/; +var re = /(.*)\.(\d+)$/; the '?' has nothing to act on.
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.
Can anyone confirm that this bug is either bogus (as I suspect, in agreement with comment #5) or fixed?
not a bug
Status: NEW → RESOLVED
Closed: 19 years ago
Resolution: --- → INVALID
Product: Core → Core Graveyard
You need to log in before you can comment on or make changes to this bug.