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

Problem with regexp_replace #75

Closed
antarey opened this issue Mar 31, 2023 · 2 comments
Closed

Problem with regexp_replace #75

antarey opened this issue Mar 31, 2023 · 2 comments

Comments

@antarey
Copy link

antarey commented Mar 31, 2023

There is a sqlite table

CREATE TABLE IF NOT EXISTS extention_files_detal (
    source_path    TEXT,
    source_text    BLOB,
    extention_type INTEGER,
    condition      TEXT,
    id             INTEGER PRIMARY KEY ON CONFLICT ROLLBACK AUTOINCREMENT
);

INSERT INTO extention_files_detal (
                                      source_path,
                                      source_text,
                                      extention_type,
                                      condition,
                                      id
                                  )
                                  VALUES (
                                      '{SYSTEMNAME_ALL_LOWER}.xml',
                                      '<?xml version=''1.0'' encoding=''utf-8''?>
<extension type="component" method="upgrade">
...
        -cbAddDBTable{<folder>language</folder>}-
....
</extension>
',
                                      NULL,
                                      NULL,
                                      1
                                  );

Query
select regexp_replace(ed.source_text, '(-cbAddDBTable{)([\s\S]*?)(}-)', '%2') from extention_files_detal ed
return

<?xml version='1.0' encoding='utf-8'?>
<extension type=""component"" method=""upgrade"">
...
        %2
....
</extension>

but should return

<?xml version='1.0' encoding='utf-8'?>
<extension type=""component"" method=""upgrade"">
...
       <folder>language</folder>
....
</extension>

thanks for the help

@nalgeon
Copy link
Owner

nalgeon commented Mar 31, 2023

The replacement expression should be $2, not %2.

@nalgeon nalgeon closed this as completed Mar 31, 2023
@antarey
Copy link
Author

antarey commented Mar 31, 2023

Sorry

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

2 participants