github.com/matrixorigin/matrixone@v1.2.0/test/distributed/cases/function/func_regular_replace.test (about)

     1  SELECT REGEXP_REPLACE('Cat Dog Cat Dog Cat','Cat', 'Tiger') 'Result';
     2  SELECT REGEXP_REPLACE('Cat Dog Cat Dog Cat', 'Cow', 'Tiger') 'Result';
     3  SELECT REGEXP_REPLACE('Cat Dog Cat Dog Cat', 'Cat', 'Tiger', 1, 2) 'Result';
     4  SELECT REGEXP_REPLACE('Cat Dog Cat Dog Cat', 'Cat', 'Tiger', 2, 1) 'Result';
     5  SELECT REGEXP_REPLACE('Cat Dog Cat Dog Cat', 'Cat', 'Tiger', 2, 2) 'Result';
     6  SELECT REGEXP_REPLACE('Cat Dog Cat Dog Cat', 'Cat', 'Tiger', 1, 0) 'Result';
     7  SELECT REGEXP_REPLACE(NULL, 'Cow', 'Tiger');
     8  SELECT REGEXP_REPLACE('Cat Dog Cat Dog Cat', NULL, 'Tiger');
     9  SELECT REGEXP_REPLACE('Cat Dog Cat Dog Cat', 'Cow', NULL);
    10  
    11  create table t1(a int, b varchar(100));
    12  insert into t1 values(1 , 'Cat Dog Cat Dog Cat Cat Dog Cat Dog Cat');
    13  insert into t1 values(2 , 'Cat Dog Cat Dog Cat Cat Dog Cat Dog Cat');
    14  insert into t1 values(3 , 'Cat Dog Cat Dog Cat Cat Dog Cat Dog Cat');
    15  insert into t1 values(4 , 'Cat Dog Cat Dog Cat Cat Dog Cat Dog Cat');
    16  insert into t1 values(5 , 'Dog Cat Dog Cat Cat Dog Cat Dog Cat Cat');
    17  insert into t1 values(6 , 'Dog Cat Dog Cat Cat Dog Cat Dog Cat Cat');
    18  insert into t1 values(7 , 'Dog Cat Dog Cat Cat Dog Cat Dog Cat Cat');
    19  insert into t1 values(8 , 'Dog Cat Dog Cat Cat Dog Cat Dog Cat Cat');
    20  SELECT a, REGEXP_REPLACE(b, 'Cat', 'tiger') from t1;
    21  drop table t1;
    22  
    23  create table t1(a int, b varchar(100));
    24  insert into t1 values(1 , 'Cat Dog Cat Dog Cat Cat Dog Cat Dog Cat');
    25  insert into t1 values(2 , 'Cat Dog Cat Dog Cat Cat Dog Cat Dog Cat');
    26  insert into t1 values(3 , 'Cat Dog Cat Dog Cat Cat Dog Cat Dog Cat');
    27  insert into t1 values(4 , 'Cat Dog Cat Dog Cat Cat Dog Cat Dog Cat');
    28  insert into t1 values(5 , 'Dog Cat Dog Cat Cat Dog Cat Dog Cat Cat');
    29  insert into t1 values(6 , 'Dog Cat Dog Cat Cat Dog Cat Dog Cat Cat');
    30  insert into t1 values(7 , 'Dog Cat Dog Cat Cat Dog Cat Dog Cat Cat');
    31  insert into t1 values(8 , 'Dog Cat Dog Cat Cat Dog Cat Dog Cat Cat');
    32  SELECT a, REGEXP_REPLACE(b, 'Cat', 'pig', 3) from t1;
    33  drop table t1;
    34  
    35  create table t1(a int, b varchar(100));
    36  insert into t1 values(1 , 'Cat Dog Cat Dog Cat Cat Dog Cat Dog Cat');
    37  insert into t1 values(2 , 'Cat Dog Cat Dog Cat Cat Dog Cat Dog Cat');
    38  insert into t1 values(3 , 'Cat Dog Cat Dog Cat Cat Dog Cat Dog Cat');
    39  insert into t1 values(4 , 'Cat Dog Cat Dog Cat Cat Dog Cat Dog Cat');
    40  insert into t1 values(5 , 'Dog Cat Dog Cat Cat Dog Cat Dog Cat Cat');
    41  insert into t1 values(6 , 'Dog Cat Dog Cat Cat Dog Cat Dog Cat Cat');
    42  insert into t1 values(7 , 'Dog Cat Dog Cat Cat Dog Cat Dog Cat Cat');
    43  insert into t1 values(8 , 'Dog Cat Dog Cat Cat Dog Cat Dog Cat Cat');
    44  SELECT a, REGEXP_REPLACE(b, 'Cat', 'taC', 3, 2) from t1;
    45  drop table t1;
    46  
    47  DROP TABLE IF EXISTS t;
    48  CREATE TABLE t(str1 VARCHAR(20), str2 CHAR(20));
    49  INSERT INTO t VALUES ('W * P', 'W + Z - O'), ('have has having', 'do does doing');
    50  INSERT INTO t VALUES ('XV*XZ', 'PP-ZZ-DXA'), ('aa bbb cc ddd', 'k ii lll oooo');
    51  SELECT REGEXP_REPLACE(str1, '*', 'i'), REGEXP_REPLACE(str2,'hav','hiv') FROM t;
    52  drop table t;