Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
matlab最有效的部分字符串减法/regex_Regex_Matlab - Fatal编程技术网

matlab最有效的部分字符串减法/regex

matlab最有效的部分字符串减法/regex,regex,matlab,Regex,Matlab,我有一个项目,我有一个巨大的电子邮件地址列表(即。johnhahifas@example.com)我还列出了5000个最常见的名字(如约翰、吉姆等) 我正在尝试为每个电子邮件地址删除任何出现在电子邮件中的名字,例如: johnhahifas@example.com变成hahifas@example.com benTTTben@something.com变成TTT@something.com 到目前为止,我提出了一个regex解决方案和一个strfind解决方案,regexprep要快得多;我甚至

我有一个项目,我有一个巨大的电子邮件地址列表(即。johnhahifas@example.com)我还列出了5000个最常见的名字(如约翰、吉姆等)

我正在尝试为每个电子邮件地址删除任何出现在电子邮件中的名字,例如:

johnhahifas@example.com变成hahifas@example.com

benTTTben@something.com变成TTT@something.com

到目前为止,我提出了一个regex解决方案和一个strfind解决方案,regexprep要快得多;我甚至对它进行了一些优化,删除了@example.com,这样操作可能会更快;但它仍然需要永远的运行

您可以从此地址(CSV文件)下载常用的名字

我拥有的正则表达式代码:

fileID = fopen('bademails');  
emails = textscan(fileID,'%s');
str = emails{1,1}; %//Loaded in the emails

fileID = fopen('CSV_Database_of_First_Names.csv');  
names = textscan(fileID,'%s');
Names = lower(names{1,1}); %//Loaded in the Names

K = regexprep(str,Names,''); %Regex on Names

任何更快的解决方案都将不胜感激,提前感谢

benTTTben@somethingben.comben
?我对Spark中的所有电子邮件进行了分类,以便它们都有有效的域,在我的情况下不会发生某些事情Ben.comben…你对其进行了分析吗?你确定,大部分时间都花在regexprep上,而不是textscan上吗?我处理了5000封电子邮件(在名字列表中大概有5500封)textscan,其余的计算耗时0.5秒,regex耗时38秒……如果你想快速解决这类问题,最好不要使用Matlab。。。我个人会用所有的名字做一个Trie,每个地址的字母都有一个空指针。当我在单词中前进时,指针会从树上下来,最后碰到一片叶子。。。