Skip to content

pybabel extract issue for javascript regex #616

@cdsheen

Description

@cdsheen

If a line contains p.replace(/>/g, '>').repalce('/', ''), pybabel stop extracting msgs after it.

$ pybabel --version
pybabel 2.6.0

$ cat mapping.ini
[javascript: *.js]

$ cat test.js
x = _('string1');
y = _('string2');
p.replace(/>/g, '>').repalce('/', '');
z = _('string3');

$  pybabel extract --omit-header -F mapping.ini test.js -o test.po      
extracting messages from test.js
writing PO template file to test.po

$ cat test.po
#: test.js:1
msgid "string1"
msgstr ""

#: test.js:2
msgid "string2"
msgstr ""

$
("string3" is not extracted)

Though the following lines works fine.

p.replace(/\>/g, '>').replace('/', ''); # okay if > is escaped
p.replace(/>/g, '>'); # okay if without slash (/) after
p.replace(/</g, '<').replace('/', ''); # okay for <

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions