Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add regexp_replace function #413

Open
Alexnortung opened this issue Aug 9, 2024 · 0 comments
Open

Add regexp_replace function #413

Alexnortung opened this issue Aug 9, 2024 · 0 comments

Comments

@Alexnortung
Copy link
Contributor

Here's the implementation that worked for me. I am unsure if there are some other things to be aware of between postgres and js when doing regex.

I just think it would be nice to have it out of the box from pg-mem :)

    db.public.registerFunction({
        name: 'regexp_replace',
        args: [DataType.text, DataType.text, DataType.text, DataType.text],
        returns: DataType.text,
        implementation: (x: string, pattern: string, replacement: string, flags: string) => x?.replace(new RegExp(pattern, flags), replacement),
    });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant