题解 | #邮箱验证# 正则与字符串匹配
邮箱验证
https://www.nowcoder.com/practice/8f908eeee4aa412ca88304f0acbaa1f9
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); String str = scanner.next(); String emailMatcher="[a-zA-Z0-9]+@[a-zA-Z0-9]+\\.[a-zA-Z0-9]+"; //write your code here...... if(str.matches(emailMatcher)) { System.out.println("邮箱格式合法"); } else{ System.out.println("邮箱格式不合法"); } } }
str.matches(emailMatcher)
没见过,记录
Java语法基础 文章被收录于专栏
基础语法的熟悉