'How can I get Position() using Regex to get the substring?
I have tried
Select Position((Select Binary Name Regexp ' [A-Z]{2} ' from Table in Name) from Table
to no effect as part of a larger query.
I am trying to find where embdedded acronyms exist in my table to extract themn e.g.
'Eastern Standard Time EST time zone'
I need to identify where it is so I can do a substring query to get the three words prior.
db-fiddle.com/f/u3EcFmfetkPVFYMmk8An9t/0
Solution 1:[1]
mysql> select regexp_instr(Term, ' [A-Z]{2}', 1, 1, 0, 'c') as position from Acronyms;
+----------+
| position |
+----------+
| 22 |
+----------+
The REGEXP_INSTR() function is new in MySQL 8.0, so if you use an older version of MySQL, you must upgrade.
To make the search case-sensitive, I had to add four optional arguments. See the documentation for the meaning of these arguments.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Bill Karwin |
