List:General Discussion« Previous MessageNext Message »
From:Ralf Narozny Date:July 15 2002 3:23pm
Subject:Re: character occurrence count in MySQL
View as plain text  

The regexp to match only 2 occurences of ';' would be:

regexp '^[^;]*;[^;]*;[^;]*$'

to find the number of ';' I only have an idea for something complicated:

length(<your str>) - length(replace(<your str>,';',''))

StephanieTan wrote:

>Hi all,
>I am looking for a way to count the number of a character occurrences in a
>string with MySQL. For example, I have this string "1;333;72227;00;19;1;1;"
>and I would like to return the number of ";" found in this string. Is this
>Also, I wanted to return fields that contain EXACTLY 2 ";" in the string,
>but with LIKE or REGEXP, it returned everything that has 2 or more ";"
>occurrences. Does anybody have a way to return the exact match?
>Before posting, please check:
>   (the manual)
>           (the list archive)
>To request this thread, e-mail <mysql-thread114599@stripped>
>To unsubscribe, e-mail <>
>Trouble unsubscribing? Try:

Ralf Narozny
SPLENDID Internet GmbH & Co KG
Skandinaviendamm 212, 24109 Kiel, Germany
fon: +49 431 660 97 0, fax: +49 431 660 97 20

character occurrence count in MySQLStephanieTan15 Jul
  • Re: character occurrence count in MySQLRalf Narozny15 Jul