saravanan


{ City } vellore
< Country > india
* Profession *
User No # 107751
Total Questions Posted # 0
Total Answers Posted # 5

Total Answers Posted for My Questions # 0
Total Views for My Questions # 0

Users Marked my Answers as Correct # 3
Users Marked my Answers as Wrong # 5
Questions / { saravanan }
Questions Answers Category Views Company eMail




Answers / { saravanan }

Question { Alcatel, 8528 }

 write a regular expressions to fetch all the valid ip's


Answer

Hi,




check this out 
====================




I am trying to match first octet in an valid IP address ,Please copy and paste for the remaining octet




regexp {^([1-9]|[0-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5]).} $ip match first




I have matched in below order ...
1-10




11-99




100-199




200-249




250-255 

Is This Answer Correct ?    0 Yes 1 No

Question { Alcatel, 8528 }

 write a regular expressions to fetch all the valid ip's


Answer

set ip "244.168.123.23"




regexp {([0-9]+).([0-9]+).([0-9]+).([0-9]+)} $ip match a b c d 








if {$a <=255 & $b <=255 & $c <=255  & $d <=255} {




puts "$ip is valid ip address"




} else {




puts "$ip is not valid address"




}

Is This Answer Correct ?    1 Yes 1 No


Question { HCL, 9289 }

write a program to the given ip is valid private address or not(192.168.1.1)?


Answer

#169.254.0.0 through 169.254.255.255




#172.16.0.0 through 172.31.255.255 




#192.168.0.0 through 192.168.255.255

#10.0.0.0 10.255.255.255




set a "10.78.80.2" or 

// a could be any private range the below regexp will match ,if u provide other than private range it will throw an error 

regexp {^(10|169|172|192).([0-9]+|[0-9][0-9]+|1[0-9][0-9]+|2[0-4][0-9]+|25[0-5]+).([0-9]|[0-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5]).([0-9]|[0-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])} $a match 




puts $match

Is This Answer Correct ?    0 Yes 0 No

Question { HCL, 9289 }

write a program to the given ip is valid private address or not(192.168.1.1)?


Answer

#10.0.0.0 through 10.255.255.255 




#169.254.0.0 through 169.254.255.255




#172.16.0.0 through 172.31.255.255 




#192.168.0.0 through 192.168.255.255




set a "10.78.80.2"
regexp {^(10|169|172|192).([0-9]+|[0-9][0-9]+|1[0-9][0-9]+|2[0-4][0-9]+|25[0-5]+).([0-9]|[0-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5]).([0-9]|[0-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])} $a match i




puts $match

Is This Answer Correct ?    0 Yes 1 No

Question { HCL, 8587 }

{Anu Anudeep Anukumar Amar Amaravathi Aruna}
is their any possibility to find the letter "a"in the given list? if yes how?


Answer

set str {Anu Anudeep Anukumar Amar Amaravathi Aruna}




foreach i $str {




if {[regexp {(A)} $i match ] } {




puts $match
}
}

Is This Answer Correct ?    2 Yes 2 No