The problem that regular expressions cannot match text in Node.js

  node.js, question

There is a regular:

^    description(?  s).*?  (?  =^    name:\n)

Escape function I use:

RegExp.escape= function(s) {
    return s.replace(/[-\/\\^$*加?.()|[\]{}]/g, '\\$&');
};

In the program, escape it into the following form:

/\^    description\(\?  s\)\.\*\?  \(\?  =\^    name:\\n\)/g

The text I want to match is as follows:

365230:
 basePrice: 2415.0
 description:
 de: Ultraleichte Legierung, die die maximale Stärke der Dropsuitpanzerung
 steigert, ohne dabei die Bewegungsgeschwindigkeit einzuschränken.
 en: Ultra-light alloy that increases the maximum strength of dropsuit armor
 without affecting movement speed.
 es: Una aleación ultraligera aumenta la fuerza máxima del blindaje de los
 trajes de salto sin afectar a su velocidad de movimiento.
 fr: Alliage ultra-léger qui augmente la force maximale de l'armure de la combinaison
 sans affecter la vitesse de déplacement.
 it: Lega leggerissima che aumenta la solidità massima della corazza dell'armatura
 senza penalizzare la velocità di movimento.
 Ja: Motion Speed に Affects を and す, こ, と, な, く to Lower the Amount of Superalloy on the Maximum Strength を.
 ru: Сверхлегкий сплав, который увеличивает максимальную прочность брони скафандров
 без ущерба скорости передвижения.
 groupID: 351121
 marketGroupID: 365245
 name:
 de: Verbesserte Ferroscale-Platten
 en: Enhanced Ferroscale Plates
 es: Placas de ferroescamas mejoradas
 fr: Plaques Ferroscale optimisées
 it: Lamiere Ferroscale perfezionate
 Ja: Enhanced
 ru: Улучшенные пластины 'Ferroscale'
 portionSize: 1
 published: true
 volume: 0.01

The goal is to remove the following from the text:

description:
 de: Ultraleichte Legierung, die die maximale Stärke der Dropsuitpanzerung
 steigert, ohne dabei die Bewegungsgeschwindigkeit einzuschränken.
 en: Ultra-light alloy that increases the maximum strength of dropsuit armor
 without affecting movement speed.
 es: Una aleación ultraligera aumenta la fuerza máxima del blindaje de los
 trajes de salto sin afectar a su velocidad de movimiento.
 fr: Alliage ultra-léger qui augmente la force maximale de l'armure de la combinaison
 sans affecter la vitesse de déplacement.
 it: Lega leggerissima che aumenta la solidità massima della corazza dell'armatura
 senza penalizzare la velocità di movimento.
 Ja: Motion Speed に Affects を and す, こ, と, な, く to Lower the Amount of Superalloy on the Maximum Strength を.
 ru: Сверхлегкий сплав, который увеличивает максимальную прочность брони скафандров
 без ущерба скорости передвижения.
 groupID: 351121
 marketGroupID: 365245

The final effect is as follows:

365230:
 basePrice: 2415.0
 name:
 de: Verbesserte Ferroscale-Platten
 en: Enhanced Ferroscale Plates
 es: Placas de ferroescamas mejoradas
 fr: Plaques Ferroscale optimisées
 it: Lamiere Ferroscale perfezionate
 Ja: Enhanced
 ru: Улучшенные пластины 'Ferroscale'
 portionSize: 1
 published: true
 volume: 0.01

Check whether the regularity matches in the program:

re1.test(data);

Returnfalse

What is the problem?

Your regularity does not match the target text


Feel free to write one.

var reg = /(?  :\t| )*description:(?  :\r\n|\r|\n)((?  :\t| )*(?  : \w plus:)?  .*(?  :\r\n|\r|\n))*?  (?  =(?  :\t| )*name:)/g;