Guy Louzon
Guy Louzon

Reputation: 1203

MySQL Locate a 1st lowercase letter inside a string

Is there any way using MySQL statements to find the location where the 1st lowercase letter appears ? for example, I would like to get the number 7 (the location of the 1st lowercase letter "a") should I run the needed statements on the string

"MARY Had a little lamb"

Upvotes: 0

Views: 55

Answers (1)

Gordon Linoff
Gordon Linoff

Reputation: 1269873

You can use regexp_instr() (at least in MySQL 8+). However, you need a case sensitive collation:

select regexp_instr('MARY Had a little lamb' collate utf8mb4_bin, '[a-z]')

Upvotes: 2

Related Questions