on 2023 May 08 8:03 AM
what is the best way to validate a string against IP Address?
I tried using this, it works.
select 'is valid ip address' where '192.168.0.11' similar to '[0-9]+.[0-9]+.[0-9]+.[0-9]+'
But I have problem with this
select 'is valid ip address' where '192.16845444.0.11' similar to '[0-9]+.[0-9]+.[0-9]+.[0-9]+'
Request clarification before answering.
Here's an REGEXP sample for IP addresses from the docs – I have not tested it myself:
((2(5[0-5]|[0-4][0-9])|1([0-9][0-9])|([1-9][0-9])|[0-9])\\.){3}(2(5[0-5]|[0-4][0-9])|1([0-9][0-9])|([1-9][0-9])|[0-9])
You may also check general regex samples for IP addresses like these, just make sure the syntax is also supported by SQL Anywhere.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
74 | |
30 | |
9 | |
7 | |
7 | |
6 | |
6 | |
4 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.