Skip to content

Beginning of line anchor doesn't seem to work in REGEXP_REPLACE #1

@bendavis78

Description

@bendavis78

Here's a normal replacement, without any anchors (works fine):

mysql> SELECT REGEXP_REPLACE('ABCABC', 'A', '*');
+------------------------------------+
| REGEXP_REPLACE('ABCABC', 'A', '*') |
+------------------------------------+
| *BC*BC                             |
+------------------------------------+
1 row in set (0.00 sec)

If we add the beginning of line anchor, it fails to replace:

mysql> SELECT REGEXP_REPLACE('ABCABC', '^A', '*');
+-------------------------------------+
| REGEXP_REPLACE('ABCABC', '^A', '*') |
+-------------------------------------+
| ABCABC                              |
+-------------------------------------+
1 row in set (0.00 sec)

End of line anchor works fine:

mysql> SELECT REGEXP_REPLACE('ABCABC', 'C$', '*');
+-------------------------------------+
| REGEXP_REPLACE('ABCABC', 'C$', '*') |
+-------------------------------------+
| ABCAB*                              |
+-------------------------------------+
1 row in set (0.00 sec)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions