#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. Jqgrid 序号列宽度调整

    // 遍历jqgrid 使其序号列宽度为45 function setwidth() { $("table[role='grid']").each(function () {//j ...

  2. Markdown的入门教程,非常的使用

    原文链接: https://www.jianshu.com/p/20e82ddb37cb 链接地址  点我      粘贴进来的内容竟然没有图片,好气呦 目录 概述 简介 官方文档 Markdown编 ...

  3. Android 开发 屏幕常亮的3个方法

    第一种 xml文件中的顶层布局添加属性: android:keepScreenOn="true" 第二种 在Window设置flag: getWindow().addFlags(W ...

  4. Codeigniter 数据库操作事务情况下获取不到last_insert_id()

    开发中,数据库Insert使用了事务,如果 $this->db->insert_id() 放在 $this->db->trans_complete(); 这句语句之后,$thi ...

  5. idea展示runDashboard的窗口

    一.idea的runDashboard打开workspace.xml文件之后,找到component为RunDashboard的节点处,然后在component标签里添加<option name ...

  6. hbase表内存的分布

  7. Vuejs实战项目:登陆页面

    1.在view文件夹下创建login文件夹,创建index.vue:代表登录的组件 配置router.js,导入登录组件 import Vue from "vue"; import ...

  8. Luogu P1948 [USACO08JAN]电话线Telephone Lines(最短路+dp)

    P1948 [USACO08JAN]电话线Telephone Lines 题意 题目描述 Farmer John wants to set up a telephone line at his far ...

  9. jsonRPC

    <?php /** * Simple JSON-RPC interface. */ namespace org; class JsonRpc{ protected $host, $port, $ ...

  10. mybatis深入理解(六)-----MyBatis的二级缓存的设计原理

    MyBatis的二级缓存是Application级别的缓存,它可以提高对数据库查询的效率,以提高应用的性能.本文将全面分析MyBatis的二级缓存的设计原理. 1.MyBatis的缓存机制整体设计以及 ...