Xi Vix
Xi Vix

Reputation: 1361

split mysql regex into multiple lines

I have a very long MySQL regex query that I would like to split into multiple lines but I haven't figured out how.
Short version:
select * from table.ips where ipip not regexp '^4\.|^8\.|^12\.|^18\.' order by ipID;

Multi-line non-working version:

select * from table.ips where ipip not regexp '

^4\\.|

^8\\.|

^12\\.|

^18\\.

' order by ipID;    

Thanks in advance.

Upvotes: 1

Views: 661

Answers (1)

Robin
Robin

Reputation: 9644

I don't think there's a free spacing mode in mysql regex...

How about using CONCAT?

select * from table.ips where ipip not regexp concat(
    '^4\\.|',
    '^8\\.|',
    '^12\\.|',
    '^18\\.'
)

Upvotes: 2

Related Questions