JavaScript math sqrt() method

The JavaScript math sqrt() method is used to get the square root of a number. Syntax: Math.sqrt(n) Parameters n: It represents the number whose square root have to be get. Returns Square root value of a number. Example <!DOCTYPE html> <html> <body> <script> document.writeln(Math.sqrt(625)); </script> </body> </html><!DOCTYPE html> <html> <body> <script> document.writeln(Math.sqrt(625)); </script> </body> </html> … Read more

java regex pattern validate html tag

Regular expression html tag pattern <("[^"]*"|'[^’]*’|[^’">])*><("[^"]*"|'[^']*'|[^'">])*> This regular expression refers to a pattern which start with an opening tag “

java regex pattern validate date

Regular expression date pattern (0?[1-9]|[12][0-9]|3[01])/(0?[1-9]|1[012])/((19|20)\d\d)(0?[1-9]|[12][0-9]|3[01])/(0?[1-9]|1[012])/((19|20)\d\d) This regular expression refers to a pattern which validates the date in dd/mm/yyyy pattern. Example package com.w3schools;   import java.util.ArrayList; import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern;   public class RegexTest { private static final String PATTERN = "(0?[1-9]|[12][0-9]|3[01])/(0?[1-9]|1[012])/((19|20)\d\d)"; public static boolean validate(final String date){ Pattern pattern = Pattern.compile(PATTERN); Matcher matcher … Read more

java regex pattern validate 24 hours format

Regular expression time in 24 hours format pattern ([01]?[0-9]|2[0-3]):[0-5][0-9]([01]?[0-9]|2[0-3]):[0-5][0-9] This regular expression refers to a pattern which start from 0-23 or 00-23 then a semi colon (:) and follow by 00-59. Example package com.w3schools;   import java.util.ArrayList; import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern;   public class RegexTest { private static final String PATTERN = "([01]?[0-9]|2[0-3]):[0-5][0-9]"; … Read more

java regex pattern validate 12 hours format

Regular expression time in 12 hours format pattern (1[012]|[1-9]):[0-5][0-9](\s)?(?i)(am|pm)(1[012]|[1-9]):[0-5][0-9](\s)?(?i)(am|pm) This regular expression refers to a pattern which start from 0-12, then a semi colon (:) and follow by 00-59, and end with am or pm. Example package com.w3schools;   import java.util.ArrayList; import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern;   public class RegexTest { private static final … Read more

java regex pattern validate ip address

Regular expressions Regular expressions represents a sequence of symbols and characters expressing a string or pattern to be searched for within a longer piece of text. The abbreviation for regular expression is regex. In programming regular expressions are mainly used to define constraint on strings like password, email validation. Regular expression ip address pattern ^([01]?\d\d?|2[0-4]\d|25[0-5])\.([01]?\d\d?|2[0-4]\d|25[0-5])\. … Read more

java regex pattern validate image file extension

Regular expression image file extension pattern ([^\s]+(\.(?i)(jpg|png|gif|bmp))$)([^\s]+(\.(?i)(jpg|png|gif|bmp))$) This regular expression refers to a pattern which must have 1 or more strings (but not white space), follow by dot “.” and string end in “jpg” or “png” or “gif” or “bmp”, and the file extensive is case-insensitive. Example package com.w3schools;   import java.util.ArrayList; import java.util.List; import … Read more

java regex pattern validate hex code

Regular expression hex code pattern #([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$ This regular expression refers to a pattern which must start with a “#” symbol, follow by a letter from “a” to “f”, “A” to “Z” or a digit from “0” to 9″ with exactly 6 or 3 length. Example package com.w3schools;   import java.util.ArrayList; import java.util.List; import java.util.regex.Matcher; import … Read more

java regex pattern validate password

Regular expression password pattern ((?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[@#$%]).{6,15})((?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[@#$%]).{6,15}) This regular expression refers to a pattern with at least one digit, one upper case letter, one lower case letter and one special symbol (“@# Example package com.w3schools;   import java.util.ArrayList; import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern;   public class RegexTest { private static final String PATTERN = "((?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[@#$%]).{6,15})"; public … Read more

java regex pattern validate email

Regular expression email pattern ^[_A-Za-z0-9-\+]+(\.[_A-Za-z0-9-]+)*@[A-Za-z0-9-]+(\.[A-Za-z0-9]+)*(\.[A-Za-z]{2,})$^[_A-Za-z0-9-\+]+(\.[_A-Za-z0-9-]+)*@[A-Za-z0-9-]+(\.[A-Za-z0-9]+)*(\.[A-Za-z]{2,})$ This regular expression refers to a pattern which must start with “_A-Za-z0-9-\+” , optional follow by “.[_A-Za-z0-9-]”, and end with a “@” symbol. The email’s domain name must start with “A-Za-z0-9-“, follow by first level Tld (.com, .net) “.[A-Za-z0-9]” and optional follow by a second level Tld (.com.au, .com.my) “\.[A-Za-z]{2,}”, … Read more