知识点:
1.数组名是数组首元素的地址。
正则表达式
a a|b [abc] a-z :匹配a, a或b ,abc中任何一个,a-z中任何一个(小写字符串)
a+ [a-z0-9]:匹配多个a,匹配小写字符及数字
[a-z0-9]+:匹配多个小写字符及数字
字符串匹配:自动机,正则表达式
C++ 出错:
//#error This file requires compiler and library support for the \
//ISO C++ 2011 standard. This support is currently experimental, and must be \
//enabled with the -std=c++11 or -std=gnu++11 compiler options.
处理:
在Dev++ 工具栏修改编译选项,加上 -std=c++11
// 字符匹配,正则表达式
#include <iostream>
#include <regex>
using namespace std;
int main(){
string str = "adf d";
regex r("[a-z]+");
cout << regex_match(str, r) << endl;
return 0;
}
Java
package n1_arrayString;
import java.util.regex.Pattern;
public class Nstring {
public static void main(String[] args) {
String site = "www.runoob.com";
int len = site.length();
System.out.println( "菜鸟教程网址长度 : " + len );
// 正则表达式
String email = "abc@123com";
String r = "[a-z0-9]+@[a-z0-9]+\\.[a-z0-9]";
System.out.println(Pattern.matches(r, email));
// false
}
}