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的更多相关文章

  1. 【JAVA、C++】LeetCode 010 Regular Expression Matching

    Implement regular expression matching with support for '.' and '*'. '.' Matches any single character ...

  2. LeetCode 010 Regular Expression Matching

    题目描述:Regular Expression Matching Implement regular expression matching with support for '.' and '*' ...

  3. Java for LeetCode 044 Wildcard Matching

    Implement wildcard pattern matching with support for '?' and '*'. '?' Matches any single character. ...

  4. leetcode python 010

    #实现正则表达式匹配并支持'.'和'*'.#''匹配任何单个字符.#'*'匹配前面元素的零个或多个.#匹配应覆盖整个输入字符串(非部分).##Some examples:##isMatch(" ...

  5. 【LeetCode】010. Regular Expression Matching

    Implement regular expression matching with support for '.' and '*'. '.' Matches any single character ...

  6. [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 ...

  7. [LeetCode] Longest Palindrome 最长回文串

    Given a string which consists of lowercase or uppercase letters, find the length of the longest pali ...

  8. [LeetCode] Range Sum Query - Mutable 区域和检索 - 可变

    Given an integer array nums, find the sum of the elements between indices i and j (i ≤ j), inclusive ...

  9. [LeetCode] Bitwise AND of Numbers Range 数字范围位相与

    Given a range [m, n] where 0 <= m <= n <= 2147483647, return the bitwise AND of all numbers ...

  10. [LeetCode] Restore IP Addresses 复原IP地址

    Given a string containing only digits, restore it by returning all possible valid IP address combina ...

随机推荐

  1. C语言--浮点数

    在程序中使用浮点数 -- 浮点数的精确性有限 -- 在从c语言中float类型的精确度只到小数点的7位 -- 浮点数只能在一定范围内去相信它 -- 在有精确度高的要求下不要使用浮点数(在算钱的时候,误 ...

  2. python-day18(正式学习)

    目录 numpy模块 numpy简介 为什么要用numpy 创建numpy数组 numpy数组的基本属性 获取numpy数组的行列数 切割numpy数组 numpy数组元素替换 numpy数组的合并 ...

  3. logging模块及日志框架

    logging模块及日志框架 logging模块 一.导入方式 import logging 二.作用 写日志 三.模块功能 3.1 经常使用 # V1 import logging logging ...

  4. 10.jQuery之停止动画排队stop方法(重点)

    重点:stop,在实际项目中,这个细节很重要 <style> * { margin: 0; padding: 0; } li { list-style-type: none; } a { ...

  5. vue学习【二】vue结合axios动态引用echarts

    大家好,我是一叶,本篇是vue学习的第二篇,本篇将要讲述vue结合axios动态引用echarts. 在vue中,异步刷新使用的是axios,类似于大家常用的ajax,其实axios已经是vue的第二 ...

  6. Css布局 响应式布局介绍

    1. 概念: 写一套css样式可以同时适配多个终端,是为解决移动互联网诞生的. 2. 作用: 面对不同的分辨率设备灵活性强,能够快捷解决多设备显示适应问题 3. 原理 媒体查询 ① 外联式媒体查询语法 ...

  7. 【Java】 ArrayList和LinkedList实现(简单手写)以及分析它们的区别

    一.手写ArrayList public class ArrayList { private Object[] elementData; //底层数组 private int size; //数组大小 ...

  8. kali下纯文本与窗口环境切换

    切到纯文本环境,想返回 试了半天ctrl+alt+f7不行,  最后我想试试ctrl+alt+f8竟然成了: 而且那是之前以root账户登录图像界面时切换回去是f8,普通用户是f9 ,为何如此,我还不 ...

  9. Ubuntu:MySQL与phpmyadmin安装、配置并使用。

    0. 小建议 Ubuntu 16.04.因为MySQL对于Ubuntu 18.04不是很适配,会出现终端MySQL无法输入中文等问题.如果用Ubuntu 18.04,会需要多解决很多细节问题. 建议将 ...

  10. kbd_mode - 显示或者设置键盘模式

    总览 (SYNOPSIS) kbd_mode [ -auks ] 描述 (DESCRIPTION) 如果 没有 参数 kbd_mode 会 显示 当前 键盘 的 模式, 如果 有 参数, 它会把 键盘 ...