-2

The REGEXP function only returns true or false, and can't be used to replace strings either. Is there any way I can actually get the matching string itself, or at least its position?

Edit: Sorry, but this is not a duplicate to the replace question, it might well be that there is some way to access the regex match in another context.

Community
  • 1
  • 1
gmolau
  • 2,815
  • 1
  • 22
  • 45
  • Whatever you;re doing, you're doing it wrong. – Salman A Sep 05 '16 at 20:17
  • @WiktorStribiżew could you please reopen the question? I had clearly cited the other question as an example only of what kind of things I'm looking for, there might be other ways to achieve what I want. – gmolau Sep 05 '16 at 20:29
  • No. There's no way to get the match. There's also no apostrophe in "its" (when used as the possessive form of "it"). – Bohemian Sep 05 '16 at 20:47
  • Thanks, I've fixed it. – gmolau Sep 05 '16 at 20:55

2 Answers2

0

Is there any way I can actually get the matching string itself,

No. Not in native MySQL. (Why ask why not? There just isn't.)

There's a UDF offering it, which you can add to your server if you control your server. http://www.mysqludf.org/

O. Jones
  • 103,626
  • 17
  • 118
  • 172
0

MariaDB has REGEXP_REPLACE(); perhaps that is what you are looking for?

Rick James
  • 135,179
  • 13
  • 127
  • 222
  • Yeah, that would be it, but I can't switch systems for that. Weird though that MySQL has been unable to implement that for [almost ten years](https://bugs.mysql.com/bug.php?id=27389) now. I thought there might be a way to at least get at the matches, but it doesn't seem so. – gmolau Sep 05 '16 at 21:56