[LeetCode]-010-Regular_Expression_Matching
Implement regular expression matching with support for '.' and '*'.
'.' Matches any single character.
'*' Matches zero or more of the preceding element.
The matching should cover the entire input string (not partial).
The function prototype should be: bool isMatch(const char *s, const char *p)
Some examples:
isMatch("aa","a") → false
isMatch("aa","aa") → true
isMatch("aaa","aa") → false
isMatch("aa", "a*") → true
isMatch("aa", ".*") → true
isMatch("ab", ".*") → true
isMatch("aab", "c*a*b") → true
题目:正则表达式匹配
public class Solution{
public boolean isMatch(String s, String p) {
Pattern pattern = Pattern.compile(p);
Matcher matcher = pattern.matcher(s);
return matcher.matches();
}
public static void main(String[] args){
String param1 = "aa",param2 = ".*";
if(args.length==2){
param1 = args[0];
param2 = args[1];
}
Solution solution = new Solution();
boolean res = solution.isMatch(param1,param2);
System.out.println(res);
}
}
[LeetCode]-010-Regular_Expression_Matching的更多相关文章
- 【JAVA、C++】LeetCode 010 Regular Expression Matching
Implement regular expression matching with support for '.' and '*'. '.' Matches any single character ...
- LeetCode 010 Regular Expression Matching
题目描述:Regular Expression Matching Implement regular expression matching with support for '.' and '*' ...
- Java for LeetCode 044 Wildcard Matching
Implement wildcard pattern matching with support for '?' and '*'. '?' Matches any single character. ...
- leetcode python 010
#实现正则表达式匹配并支持'.'和'*'.#''匹配任何单个字符.#'*'匹配前面元素的零个或多个.#匹配应覆盖整个输入字符串(非部分).##Some examples:##isMatch(" ...
- 【LeetCode】010. Regular Expression Matching
Implement regular expression matching with support for '.' and '*'. '.' Matches any single character ...
- [LeetCode] Maximum XOR of Two Numbers in an Array 数组中异或值最大的两个数字
Given a non-empty array of numbers, a0, a1, a2, … , an-1, where 0 ≤ ai < 231. Find the maximum re ...
- [LeetCode] Longest Palindrome 最长回文串
Given a string which consists of lowercase or uppercase letters, find the length of the longest pali ...
- [LeetCode] Range Sum Query - Mutable 区域和检索 - 可变
Given an integer array nums, find the sum of the elements between indices i and j (i ≤ j), inclusive ...
- [LeetCode] Bitwise AND of Numbers Range 数字范围位相与
Given a range [m, n] where 0 <= m <= n <= 2147483647, return the bitwise AND of all numbers ...
- [LeetCode] Restore IP Addresses 复原IP地址
Given a string containing only digits, restore it by returning all possible valid IP address combina ...
随机推荐
- Let和Const的使用
ES2015(ES6) 新增加了两个重要的 JavaScript 关键字: let 和 const. let 声明的变量只在 let 命令所在的代码块内有效,const 声明一个只读的常量,一旦声明, ...
- mysql复制表结构,复制表数据
MYSQL 复制表 show create table table_name:查看表的建表语句.该语句包含了原数据表的结构,索引等. 使用 SHOW CREATE TABLE 命令获取创建数据表(CR ...
- Mac下的常用快捷键总结
由于在公司的时候是使用的Windows下进行开发工作,但是回家之后,有时候要使用自己的Mac进行开发等工作,那么流利的使用快捷键就变得尤其的重要. 1. 退出软件 cmd + q 2.将最前面的窗口最 ...
- android中的rn项目更新gradle及补充二
修改build.gradle的版本,com.android.tools.build:gradle:2.1.0, 改为更高的,然后更改gradle/wrapper/gradle-wrapper.prop ...
- java中too many characters in character literal
IDE里发现 too many characters in character literal 翻译过来就是 字符中的字符过多 , 一般情况是:把 多个文字 放在了 '' (单引号)里,应该放到 &q ...
- bcdedit删除uefi多余项
1.检查是否有多余的启动项:用管理员权限的cmd运行Bcdedit /enum firmware 2.保存现在的所有引导项Bcdedit /export savebcdsavebcd是导出的文件名 3 ...
- python-字符编码的转换
python-字符编码的转换 1.了解基础知识 ASCII 一个英文,占一个字节.只能存英文和特殊字符. gb2312 约可以存7000中文 gb1830 约可以存27000中文 gbk 默认中文, ...
- AIX中crontab和at 定时任务
1.crontab crontab文件用于在指定日期和时间周期性地执行作业 crontab 作业存放在/var/spool/cron/crontabs/$USER cron根据crontab文件项运行 ...
- nginx的高级配置和优化
Nginx的高级配置(优化) 针对内核的配置优化 1)net.core.netdev_max_backlog 表示当网络接口接收数据包的速度大于内核处理这些包块的时候,允许发送到队列的数据包的最大数目 ...
- PAT Basic 1033 旧键盘打字 (20 分)
旧键盘上坏了几个键,于是在敲一段文字的时候,对应的字符就不会出现.现在给出应该输入的一段文字.以及坏掉的那些键,打出的结果文字会是怎样? 输入格式: 输入在 2 行中分别给出坏掉的那些键.以及应该输入 ...