0

my problem is quite minor. I do not get along with the syntax of JavaScript What I want to do is actually cause the following code to occur: with this regex: ^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]).){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$

   <!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<script src="https://code.jquery.com/jquery-3.3.1.min.js"
        integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8="
        crossorigin="anonymous">
</script>
<meta charset="utf-8" />
<title></title>
<script>

    $(document).ready(function () {
        $("#but").click(check);
    });

    function check() {
        var str = $("#dataCon").val();
        var result = str.match(/\d/g);
       alert(result);
    }
</script>
</head>
<body>
<textarea id="dataCon"></textarea>
<button id="but">Click here</button>
</body>
</html>
  • Will [this](https://stackoverflow.com/questions/31684083/validate-if-input-string-is-a-number-between-0-255-using-regex) give you the answer you're looking for? – David784 Aug 12 '18 at 17:40
  • What's the problem? You can make the regex a bit shorter, something like [`^(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d).?\b){4}$`](https://regex101.com/r/tU3gC3/69) – bobble bubble Aug 12 '18 at 18:13

0 Answers0