02-MOOC-数组与字符串

知识点:

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
	}

}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值