Dev Helpers
← Back

Preserve a regular expression

Preserve a regular expression using Node.js.

Open this example in the interactive library

Source code

import { serialize, deserialize, Serializer, Deserializer } from "node:v8";
const roundTrip = (value) => deserialize(serialize(value));
console.log(roundTrip(/hello/gi).flags);

Sample output

gi