function exist=wildcardl(pat)
%pat='http://*.huawei.com';->%pat='http://(\w+\.)+huawei.com'
pat=strrep(pat,'*.','(\w+\.)+');
pat=strcat(strcat('^',pat),'$');
str=textread('data.txt','%s','delimiter','\n');
result=regexp(str,pat,'start');
exist=str(cellfun('length',result)==1,1);
function exist=wildcardr(pat)
pat=strrep(pat,'.*','(\.\w+)+');
pat=strcat(strcat('^',pat),'$');
str=textread('data.txt','%s','delimiter','\n');
result=regexp(str,pat,'start');
exist=str(cellfun('length',result)==1,1);
function exist=wildcardlr(pat)
%pat='http://*.huawei.com';->%pat='http://(\w+\.)+huawei.com'
pat=strrep(pat,'*.','(\w+\.)+');
pat=strrep(pat,'.*','(\.\w+)+');
pat=strcat(strcat('^',pat),'$');
str=textread('data.txt','%s','delimiter','\n');
result=regexp(str,pat,'start');
exist=str(cellfun('length',result)==1,1);
function exist=precise(pat)
str=textread('data.txt','%s','delimiter','\n');
% exist=length(cell2mat(regexp(str,pat,'start')));
result=regexp(str,pat,'start');
exist=str(cellfun('length',result)==1,1);
%expr is a directory ,if find expr
function exist=directory(expr)
str=textread('data.txt','%s','delimiter','\n');
exist=str(strcmp(expr,str));
%expr is a box
function exist=box(expr)
txt=textread('data.txt','%s','delimiter','\n');
expr=strcat(expr,'*');
exist=length(regexp(txt,expr,'start'));
本文介绍了一种使用正则表达式进行精确和通配符匹配的方法,包括左边界、右边界以及目录和文件名的匹配策略。通过MATLAB脚本实现了对文本文件中特定模式的查找,并返回匹配的存在与否。
1187

被折叠的 条评论
为什么被折叠?



