Reputation: 4364
I am looking for a regex for MySQL which will find a row where the following:
Will match:
this is texthttp:// and no space before http
Won't match:
this is text http:// but has a space so is happy
I tried WHERE message REGEXP '[\s]http:'
and for some reason this found some but I know its not all the instances. Thanks
Upvotes: 1
Views: 74
Reputation: 17018
Match strings containing a 'nonspace' character before http://
:
regexp '[^[:space:]]http://';
See mysql regexp documentation.
mysql> select * from test;
+------------------+
| s |
+------------------+
| texthttp://text |
| http://text |
| text http://text |
| texthttp:// |
| text http:// |
+------------------+
5 rows in set (0.00 sec)
mysql> select * from test where s regexp '[^[:space:]]http://';
+-----------------+
| s |
+-----------------+
| texthttp://text |
| texthttp:// |
+-----------------+
2 rows in set (0.00 sec)
Upvotes: 2