+ 1

can anyone explain these two patterns

1st one is "^[a-zA-Z0-9+_.-]+@[a-zA-Z0-9.-]+

quot; 2nd is "^(?=.*[0-9])"+"(?=.*[a-z])(?=.*[A-Z])"+"(?=.*[@#$%^&+=])"+"(?=\\S+$).{8,20}
quot;

2nd Nov 2022, 9:46 AM
🎶💞Sravs💞🥀
🎶💞Sravs💞🥀 - avatar
7 Answers
+ 5
Try https://regexr.com You can enter a pattern, and it explains each component. Best viewed on a desktop computer for interactive mouse over effect. Also it can handle JavaScript syntax but you can put your Java regex between the / ... / slashes, and make sure to remove one of the backslash characters whenever you have to use \\ in Java.
2nd Nov 2022, 2:11 PM
Tibor Santa
Tibor Santa - avatar
0
if there is something java specific, use similar https://regex101.com/ menu has java option
3rd Nov 2022, 6:59 AM
zemiak
0
1) The regular expression pattern /^[a-zA-Z0-9+_.-]+@[a-zA-Z0-9.-]+$/ is used to match and validate email addresses. The pattern uses a combination of character classes and special characters to define the rules for the email address. The ^ character at the start of the pattern indicates that the regex should match the beginning of the string. This means that the email address must start with one or more of the characters in the character class [a-zA-Z0-9+_.-], which includes lowercase and uppercase letters, digits, the plus sign, the underscore, the period, and the hyphen. The + character after the character class indicates that the previous character or group (in this case the character class) can be matched one or more times. This means that the email address can contain any number of letters, digits, and the special characters in the character class. The @ character must be present in the email address after the local part (the part before the @ symbol), and it must be followed by one or more of
7th Dec 2022, 2:49 PM
Calviղ
Calviղ - avatar
0
2) The @ character must be present in the email address after the local part (the part before the @ symbol), and it must be followed by one or more of the characters in the character class [a-zA-Z0-9.-], which includes lowercase and uppercase letters, digits, and the period and hyphen characters. The $ character at the end of the pattern indicates that the regex should match the end of the string. This means that the email address must end with one or more of the characters in the character class [a-zA-Z0-9.-], and it must not contain any other characters after the @ symbol. In summary, the regular expression /^[a-zA-Z0-9+_.-]+@[a-zA-Z0-9.-]+$/ is used to match and validate email addresses that have a local part consisting of one or more letters, digits, and the special characters +, _, ., and -, followed by an @ symbol, and a domain part consisting of one or more letters, digits, and the special characters . and -.
7th Dec 2022, 2:50 PM
Calviղ
Calviղ - avatar
0
3) this regex pattern /^(?=.*[0-9])"+"(?=.*[a-z])(?=.*[A-Z])"+"(?=.*[@#$%^&+=])"+"(?=\\S+$).{8,20}$/ can be used to validate a password. The regular expression consists of several parts, each of which serves a specific purpose. Here's a breakdown of the parts of this regular expression: ^: This character is called the caret and it is used to match the start of a string. (?=.*[0-9]): This is a positive lookahead assertion. It checks that the string contains at least one digit (a number between 0 and 9). The ?= indicates that this is a lookahead assertion, .* indicates that any number of any character can come before the digit, and [0-9] is the range of digits that we are looking for. (?=.*[a-z]): This is another positive lookahead assertion. It checks that the string contains at least one lowercase letter (a letter between a and z).
7th Dec 2022, 3:11 PM
Calviղ
Calviղ - avatar
0
4) (?=.*[A-Z]): This is another positive lookahead assertion. It checks that the string contains at least one uppercase letter (a letter between A and Z). (?=.*[@#$%^&+=]): This is another positive lookahead assertion. It checks that the string contains at least one special character (@, #, $, %, ^, &, +, or =). (?=\S+$): This is another positive lookahead assertion. It checks that the string contains no whitespace characters (spaces, tabs, etc.). The \S character class matches any non-whitespace character, and + indicates that the preceding character can be matched one or more times. .{8,20}: This part of the regular expression matches any character, except a newline, at least 8 times and at most 20 times. This ensures that the password is at least 8 characters long and no longer than 20 characters. $: This character is called the dollar sign and it is used to match the end of a string. In summary, this regular expression is used to check that a password contains at least one digit, one lowerc
7th Dec 2022, 3:14 PM
Calviղ
Calviղ - avatar
0
5} In summary, this regular expression is used to check that a password contains at least one digit, one lowercase letter, one uppercase letter, one special character, no whitespace characters, and is at least 8 characters long and no longer than 20 characters.
7th Dec 2022, 3:14 PM
Calviղ
Calviղ - avatar