首页
题库
面试
求职
学习
竞赛
More+
所有博客
搜索面经/职位/试题/公司
搜索
我要招人
去企业版
登录 / 注册
首页
>
试题广场
>
正则表达式匹配
[编程题]正则表达式匹配
热度指数:398597
时间限制:C/C++ 1秒,其他语言2秒
空间限制:C/C++ 128M,其他语言256M
算法知识视频讲解
请实现一个函数用来匹配包括'.'和'*'的正则表达式。模式中的字符'.'表示任意一个字符,而'*'表示它前面的字符可以出现任意次(包含0次)。 在本题中,匹配是指字符串的所有字符匹配整个模式。例如,字符串"aaa"与模式"a.a"和"ab*ac*a"匹配,但是与"aa.a"和"ab*a"均不匹配
示例1
输入
"aaa","a*a"
输出
true
马上挑战
算法知识视频讲解
提交运行
算法知识视频讲解
添加笔记
求解答(358)
邀请回答
收藏(2694)
分享
提交结果有问题?
0个回答
30篇题解
添加回答
这道题你会答吗?花几分钟告诉大家答案吧!
提交观点
问题信息
字符串
难度:
0条回答
2694收藏
112225浏览
热门推荐
通过挑战的用户
洒脱的懒羊羊要发财
2023-03-12 18:00:20
牛客42096...
2023-03-06 15:43:59
staycalm1
2022-10-28 19:58:00
牛客89076...
2022-10-27 10:43:52
Pursue2...
2022-10-19 18:30:30
相关试题
分页系统的逻辑地址结构是一维的,分...
操作系统
评论
(1)
关于分段系统与分页系统的区别,描述...
操作系统
评论
(1)
已知a
40
=...
京东
职能
2019
财务
保险
评论
(1)
你说在销售运营这个岗位上会涉及到一...
评论
(1)
有20000人的就餐需求,现建了一...
评论
(1)
扫描二维码,关注牛客网
意见反馈
下载牛客APP,随时随地刷题
import java.util.*; public class Solution { public boolean match(char[] str, char[] pattern) { } }
class Solution { public: /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param str string字符串 * @param pattern string字符串 * @return bool布尔型 */ bool match(string str, string pattern) { // write code here } };
# -*- coding:utf-8 -*- class Solution: # s, pattern都是字符串 def match(self, s, pattern): # write code here
class Solution { public bool match(char[] str, char[] pattern) { // write code here } }
//s, pattern都是字符串 function match(s, pattern) { // write code here } module.exports = { match : match };
package main /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * @param s string字符串 * @param pattern string字符串 * @return bool布尔型 */ func match( s string , pattern string ) bool { // write code here }
# # 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 # # @param s string字符串 # @param pattern string字符串 # @return bool布尔型 # class Solution def match(s, pattern) # write code here end end
object Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * @param s string字符串 * @param pattern string字符串 * @return bool布尔型 */ def match(s: String,pattern: String): Boolean = { // write code here } }
object Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * @param s string字符串 * @param pattern string字符串 * @return bool布尔型 */ fun match(s: String,pattern: String): Boolean { // write code here } }
import java.util.*; public class Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * @param s string字符串 * @param pattern string字符串 * @return bool布尔型 */ public boolean match (String s, String pattern) { // write code here } }
/** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * @param s string字符串 * @param pattern string字符串 * @return bool布尔型 */ export function match(s: string, pattern: string): boolean { // write code here }
public class Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * @param s string字符串 * @param pattern string字符串 * @return bool布尔型 */ func match ( _ s: String, _ pattern: String) -> Bool { // write code here } }
struct Solution{ } impl Solution { fn new() -> Self { Solution{} } /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * @param s string字符串 * @param pattern string字符串 * @return bool布尔型 */ pub fn match(&self, s: String, pattern: String) -> bool { // write code here } }
"aaa","a*a"
true