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

[CBRD-22783] Add support for REGEXP_REPLACE function #1647

Merged
merged 77 commits into from
Feb 10, 2020

Conversation

hgryoo
Copy link
Member

@hgryoo hgryoo commented Jul 4, 2019

http://jira.cubrid.org/browse/CBRD-22783

REGEXP_REPLACE function
REGEXP_REPLACE (src, pattern, repl [, position [,occurrence [, match_type]]])

replaces occurrences in the string src that matches the regular expression pattern with the replacement string repl, and returns the result string.

Optional arguments:

  • position: the position in src to start the search. If omitted, the default value is 1.
  • occurrence: the occurrence of a match to replace. If omitted, the default value is 0 (which means match all).
  • match_type: A string to configure the behavior of matching
    • c: Case sensitive matching.
    • i: Case insensitive matching.

If any of the arguments is NULL, the return value is NULL.

Examples

SELECT REGEXP_REPLACE ('TechOnTheNet', 'a|e|i|o|u', '#', 3, 2, 'c');

=== <Result of SELECT Command in Line 1> ===

  regexp_replace('TechOnTheNet', 'a|e|i|o|u', '#', 3, 2, 'c')
======================
  'TechOnTheN#t'

1 row selected. (0.011526 sec) Committed.

SELECT REGEXP_REPLACE (name, '\w', '#') from athlete LIMIT 5;

=== <Result of SELECT Command in Line 2> ===

  regexp_replace(name, '\w', '#')
======================
  '######### #####'
  '######### #####'
  '######### ######'
  '######### ####'
  '######### ### ####'

5 rows selected. (0.017418 sec) Committed.

1 command(s) successfully processed.

This PR should be merged after #1509. To review this PR, the first commit for REGEXP_REPLACE starts from b55afda

@hgryoo hgryoo added this to the damson milestone Jan 7, 2020
src/query/regu_var.hpp Show resolved Hide resolved
@cubridci
Copy link

cubridci commented Feb 7, 2020

Build comment file:

File: src/query/query_executor.c (1 incorrect indentation(s) found)

  1758 	    /* free memory of compiled regex */

Please run 'indent -l120 -lc120' to correct the indentation


@hgryoo hgryoo merged commit 3df36a1 into CUBRID:develop Feb 10, 2020
hgryoo added a commit that referenced this pull request Feb 20, 2020
http://jira.cubrid.org/browse/CBRD-22783

- fixed matching for char range on case insensitive flag doesn't work well on Windows
- slip of concatenating suffix of matching when last matching or nothing matched
hgryoo added a commit to hgryoo/cubrid that referenced this pull request Sep 24, 2020
hgryoo added a commit to hgryoo/cubrid that referenced this pull request Sep 24, 2020
http://jira.cubrid.org/browse/CBRD-22783

- fixed matching for char range on case insensitive flag doesn't work well on Windows
- slip of concatenating suffix of matching when last matching or nothing matched
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants