This regex is used to validate ip address
regex = "^([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\.([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\.([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\.([01]?\\d\\d?|2[0-4]\\d|25[0-5])$"
/!\ modified version /!\
regex =
"^([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\.(\\1)\\.(\\1)\\.(\\1)$"
But the modified version is not working!! why it is not working??
\\1expects exact same value as matched by group 1, so in case of regex like([a-c])\\1it can match onlyaabbcc, notacsince group 1 would holdain this case.