5

I've got problem - I need to find every single phrase like AbC (small b, between two Capital letters). For Example a statement: Little John had a ProBlEm and need to know how to do tHiS.

I need to select ProBlEm and tHiS (you see, BlE and HiS, one small letter in between two capital). How can I select this?

Paweł Adamczyk
  • 223
  • 3
  • 6
  • 14

2 Answers2

1

In MySQL you can use a binary (to ensure case sensitivity) regular expression to filter for those records that contain such a pattern:

WHERE my_column REGEXP BINARY '[[:upper:]][[:lower:]][[:upper:]]'

However, it is not so straightforward to extract the substrings which match such a pattern from within MySQL. One can use a UDF, e.g. lib_mysqludf_preg, but it's probably a task more suited to being performed within your application layer. In either case, regular expressions can again help to simplify this task.

eggyal
  • 122,705
  • 18
  • 212
  • 237
  • Be aware of this warning from the [mysql manual](http://dev.mysql.com/doc/refman/5.7/en/regexp.html#operator_regexp): "The REGEXP and RLIKE operators work in byte-wise fashion, so they are not multi-byte safe and may produce unexpected results with multi-byte character sets." – mabi Jul 23 '13 at 08:40
  • Just a literal 'e' should be enough. – mabi Jul 23 '13 at 08:48
0

Firstly you have split the String. Please refer this SO Question

and then search each retrive word like

substring(word,2) LIKE '[A-Z]' COLLATE latin1_general_cs
Community
  • 1
  • 1
Prahalad Gaggar
  • 11,389
  • 16
  • 53
  • 71