#include<iostream>
using namespace std;
bool PathernMatch(char *pat, char *str)
{
char *s = NULL;
char *p = NULL;
bool star = false;
bool bBreak = false;
do
{
bBreak = false;
for (s = str, p = pat; *s; ++s, ++p)
{
switch (*p)
{
case '?':
break;
case '*':
star = true; //出现*匹配符
str = s;
pat = p;
if (!*++pat)
return true;
bBreak = true; //退出循环
break;
default:
if (*s != *p)
{
if (!star)
return false;
str++;
bBreak = true;
}
break;
}
if (bBreak) //退出循环 重新开始循环
break;
}
if (bBreak == false)
{
if (*p == '*')
++p;
return (!*p);
}
} while (true);
}
int main()
{
char a[100] = "\\Device\\*\\Content.IE5\\index.dat";
char c[100] = "\\Device\\*\\Content.IE5\\*\\index.dat";
char b[100] = "\\Device\\Harddiskvolume\\Content.IE5\\Femporary Internet Files\\Content.IE5\\index.dat";
char d[100] = "\\*\\Content.IE5\\index.dat";
char e[100] = "\*层图层\*顶";
char f[100] = "一层图层";
char g[100] = "二层图层";
char h[100] = "二三层图层";
char i[100] = "二搜索三层图层顶顶顶";

cout << PathernMatch(e, f) << endl;
cout << PathernMatch(e, g) << endl;
cout << PathernMatch(e, h) << endl;
cout << PathernMatch(e, i) << endl;
return 0;
}

C++通配符的更多相关文章

  1. jQuery选择器中,通配符[id^='code']input[id$='code'][id*='code']

     1.选择器 (1)通配符: $("input[id^='code']");//id属性以code开始的所有input标签 $("input[id$='code']&qu ...

  2. 读书笔记--SQL必知必会06--用通配符进行过滤

    6.1 LIKE操作符 通配符(wildcard),用来匹配某些值的的特殊字符. 在搜索子句中必须通过LIKE操作符使用通配符. 通配符搜索只能用于文本字段(字符串),非文本数据类型字段不能使用通配符 ...

  3. 配置IIS的通配符应用程序映射

    使用IIS 6架设网站,如果要使用伪静态的功能,可能需要设置“通配符应用程序映射(执行顺序)”. 在Windows Server 2012 r2 的IIS 8中,对应的是添加设置“通配符脚本映射”,参 ...

  4. jQuery的选择器中的通配符[id^='code'] 等示例及说明

    1.选择器 (1)通配符: $("input[id^='code']");//id属性以code开始的所有input标签 $("input[id$='code']&quo ...

  5. SpringMVC(六) RequestMapping 路径中ant风格的通配符

    SpringMVC支持路径中包含ant风格的通配符,常用的几种通配符及意义如下: ? 任意一个字符 * 任意多个字符 ** 匹配多层路径 测试控制器代码: package com.tiekui.spr ...

  6. bzoj 3507: [Cqoi2014]通配符匹配

    Description 几乎所有操作系统的命令行界面(CLI)中都支持文件名的通配符匹配以方便用户.最常见的通配符有两个,一个是星号(“”’),可以匹配0个及以上的任意字符:另一个是问号(“?”),可 ...

  7. jQuery的选择器中的通配符

    (1)通配符: $("input[id^='code']");//id属性以code开始的所有input标签 $("input[id$='code']");// ...

  8. Linux Shell 通配符、元字符、转义符【转帖】

    作者:程默 说到shell通配符(wildcard),大家在使用时候会经常用到.下面是一个实例: 1   1 2 3 4 [chengmo@localhost ~/shell]$ ls a.txt  ...

  9. 一劳永逸:域名支持通配符,ASP.NET Core中配置CORS更轻松

    ASP.NET Core 内置了对 CORS 的支持,使用很简单,只需先在 Startup 的 ConfigureServices() 中添加 CORS 策略: public void Configu ...

  10. linux中的通配符与正则表达式

    在linux中,有通配符及正则表达式,那么什么是通配符和正则表达式,什么时候用?   通配符 它是由shell解析,并且一般用于匹配文件名,实际上就是shell解释器去解析的特殊符号,linux系统通 ...

随机推荐

  1. vue 监听返回

    mounted: function() { //使用keep-alive时可以放在activated内 if (window.history && window.history.pus ...

  2. 关于python DataFrame的学习记录

    df_1 = pd.DataFrame({'A': [0, 1, 2], 'B': [3, 4, 5]}) print df_1 默认左边行index0往上递增,AB为顶部标识,数组内为内容 loc— ...

  3. 两台linux 服务器同步

    准备: 主服务器 192.168.0.1 备份服务器 192.168.0.2 备份服务器 注意需要开放873端口 而且小心selinux 开始: sudo vim /etc/rsyncd.passwd ...

  4. Vue基础知识梳理

    1. Vue 实例 1.1 创建一个Vue实例 一个 Vue 应用由一个通过 new Vue 创建的根 Vue 实例,以及可选的嵌套的.可复用的组件树组成.demo 1.2 数据与方法 数据的响应式渲 ...

  5. CGLayer和CALayer区别

    CGLayer是一种很好的缓存常绘内容的方法.注意,不要与CALayer混淆.CALayer是Core Animation中更加强大.复杂的图层对象,而CGLayer是Core Graphics中优化 ...

  6. dubbo入门学习(二)-----dubbo hello world

    一.dubbo hello world入门示例 1.提出需求 某个电商系统,订单服务需要调用用户服务获取某个用户的所有地址: 我们现在需要创建两个服务模块进行测试: 模块 功能 订单服务web模块 创 ...

  7. Spring AOP(二)--注解方式

    本文介绍通过注解@AspectJ实现Spring AOP,这里要重点说明一下这种方式实现时所需的包,因为Aspect是第三方提供的,不包含在spring中,所以不能只导入spring-aop的包,为了 ...

  8. hashMap 源码解读理解实现原理和hash冲突

    hashMap 怎么说呢. 我的理解是 外表是一个set 数组,无序不重复 . 每个set元素是一个bean ,存着一对key value 看看代码吧 package test; import jav ...

  9. ajax返回后台编译时都对,返回error

    首先看看你的dataType:‘json’  类型是否与后台获取的类型一直.特别是json的格式对不对. 第二: 红括号里的有没有加

  10. LTIME16小结(CodeChef)

    题目链接 最后一题是Splay...还没有学会..蒟蒻!!! A /****************************************************************** ...