Ericson Willians
Ericson Willians

Reputation: 7845

How can I match all elements that start with a number or a relevant symbol in MYSQL?

Here's my "where" part:

$fornecedor->where = "nome_fantasia REGEXP '^[0-9+#-]*$%'";

It does not work. How can I match it?

Upvotes: 1

Views: 29

Answers (1)

miken32
miken32

Reputation: 42719

REGEXP doesn't want % at the end. Also, your pattern searches the entire string because it starts with ^ and ends with $. Try this:

$fornecedor->where = "nome_fantasia REGEXP '^[0-9+#-]'";

This searches only for a single matching character at the beginning of the line, since you don't care about anything after that.

Upvotes: 2

Related Questions