C++参悟:正则表达式库regex

news2024/10/5 19:11:28

正则表达式库regex

  • 一、概述
  • 二、快速上手Demo
    • 1. 查找字符串
    • 2. 匹配字符串
    • 3. 替换字符串
  • 三、类关系梳理
    • 1. 主类
      • 1. basic_regex
    • 2. 算法
      • 1. regex_match
      • 2. regex_search
      • 3. regex_replace
    • 3. 迭代器
    • 4. 异常
    • 5. 特征
    • 6. 常量
      • 1. syntax_option_type
      • 2. match_flag_type
      • 3. error_type

一、概述

C++标准库为我们提供了处理字符串的正则表达式库。正则表达式是一种用于在字符串中匹配模式的微型语言。

正则表达式在查询、替换字符串的时候有很多快速的使用场景,是一个经常使用的工具。正则表达式需要使用到正则表达式的语法,这个语法是独立于编程语言外的一个工具。这个可以 在线查看和测试

菜鸟学习教程 :https://www.runoob.com/regexp/regexp-syntax.html
在这里插入图片描述

在线测试工具 :https://stackoverflow.org.cn/regex/
在这里插入图片描述

这个用到的头文件便是:

#include <regex>

二、快速上手Demo

1. 查找字符串

1. 采用迭代器查找

// 待匹配字符串
std::string s = "Some people, when confronted with a problem";

// 正则表达式匹配对象-匹配单词
std::regex word_regex("(\\w+)");

// 获取迭代器
auto words_begin = std::sregex_iterator(s.begin(), s.end(), word_regex);
auto words_end = std::sregex_iterator();

// 总元素个数
int count = std::distance(words_begin, words_end);

// 遍历元素
for (std::sregex_iterator i = words_begin; i != words_end; ++i) {
		//  查询到的匹配对象
        std::smatch match = *i;

		// 输出这个匹配对象的内容
        std::string match_str = match.str();
		std::cout << "  " << match_str << '\n';
}

/* 输出结果
Some 
people
when 
confronted
with
a
problem
*/

2. 使用算法查找

使用 std::regex_search() 查找

//常用
template< class BidirIt,
          class Alloc, class CharT, class Traits >
bool regex_search( BidirIt first, BidirIt last,
                    std::match_results<BidirIt,Alloc>& m,
                    const std::basic_regex<CharT,Traits>& e,
                    std::regex_constants::match_flag_type flags = std::regex_constants::match_default ); 
//常用
template< class CharT, class Alloc, class Traits >
bool regex_search( const CharT* str,
                    std::match_results<const CharT*,Alloc>& m,
                    const std::basic_regex<CharT,Traits>& e,
                    std::regex_constants::match_flag_type flags = std::regex_constants::match_default ); 
//常用
template< class STraits, class SAlloc,
          class Alloc, class CharT, class Traits >
bool regex_search( const std::basic_string<CharT,STraits,SAlloc>& s,
                    std::match_results<
                    typename std::basic_string<CharT,STraits,SAlloc>::const_iterator, Alloc>& m,
                    const std::basic_regex<CharT, Traits>& e,
                    std::regex_constants::match_flag_type flags = std::regex_constants::match_default ); 

template< class BidirIt
          class CharT, class Traits >
bool regex_search( BidirIt first, BidirIt last,
                    const std::basic_regex<CharT,Traits>& e,
                    std::regex_constants::match_flag_type flags = std::regex_constants::match_default );

template< class CharT, class Traits >
bool regex_search( const CharT* str,
                    const std::basic_regex<CharT,Traits>& e,
                    std::regex_constants::match_flag_type flags = std::regex_constants::match_default ); 

template< class STraits, class SAlloc,
          class CharT, class Traits >
bool regex_search( const std::basic_string<CharT,STraits,SAlloc>& s,
                    const std::basic_regex<CharT,Traits>& e,
                    std::regex_constants::match_flag_type flags =std::regex_constants::match_default );

template< class STraits, class SAlloc,
          class Alloc, class CharT, class Traits >
bool regex_search( const std::basic_string<CharT,STraits,SAlloc>&&,
                    std::match_results<typename std::basic_string<CharT,STraits,SAlloc>::const_iterator, Alloc>&,
                    const std::basic_regex<CharT, Traits>&,
                    std::regex_constants::match_flag_type flags = std::regex_constants::match_default ) = delete; 

这个函数的部分参数说明

  • 待匹配字符串(三种输入)
    1. first, last - 标识目标字符序列的范围
    2. str - 指向空终止字符序列的指针
    3. s - 标识目标字符序列的指针
  • e - 应当应用到目标字符序列的 std::regex :其实就是正则匹配对象
  • m - 匹配结果 :用的是 match_results 对象描述
  • flags - 掌管搜索行为的 std::regex_constants::match_flag_type
// 待匹配字符串
std::string lines[] = {"Roses are #ff0000",
                           "violets are #0000ff",
                           "all of my base are belong to you"};
// 正则表达式对象
std::regex color_regex("#([a-f0-9]{2})"
                           "([a-f0-9]{2})"
                           "([a-f0-9]{2})");
// 匹配结果
std::vector<std::smatch> matchs;

// 简单匹配
for (const auto &line : lines) {
	std::smatch m;
	std::cout << line << ": " << std::boolalpha
		<< std::regex_search(line, m, color_regex) << "\n";
	matchs.push_back(m);
}
    
// 输出结果
for(auto m: matchs){
	if(m.ready() && !m.empty())
		std::cout << "Useful Color: " << m.str() << "\n";
}
/* 输出结果
Roses are #ff0000: true
violets are #0000ff: true
all of my base are belong to you: false
Useful Color: #ff0000
Useful Color: #0000ff
*/

2. 匹配字符串

有两个方法都可以去匹配字符串。可以用 regex_match 或者 regex_search

因为 regex_match 只考虑完全匹配,故同一 regex 可能在 regex_match 和 std::regex_search 间给出不同的匹配

// 构造正则表达式对象
std::regex re("Get|GetValue");
std::cmatch m;

// regex_search 方法
std::regex_search("GetValue", m, re);  // 返回 true ,且 m[0] 含 "Get"
std::regex_search("GetValues", m, re); // 返回 true ,且 m[0] 含 "Get"

// regex_match 方法
std::regex_match ("GetValue", m, re);  // 返回 true ,且 m[0] 含 "GetValue"
std::regex_match ("GetValues", m, re); // 返回 false

3. 替换字符串

#include <iostream>
#include <iterator>
#include <regex>
#include <string>
 
int main()
{
   std::string text = "Quick brown fox";
   std::regex vowel_re("a|e|i|o|u");
 
   // 写结果到输出迭代器
   std::regex_replace(std::ostreambuf_iterator<char>(std::cout),
                      text.begin(), text.end(), vowel_re, "*");
 	// 等价于下面的
 	// std::cout << '\n' << std::regex_replace(text, vowel_re, "*");
 
   // 构造保有结果的字符串
   std::cout << '\n' << std::regex_replace(text, vowel_re, "[$&]") << '\n';
}

// 输出
Q**ck br*wn f*x
Q[u][i]ck br[o]wn f[o]x

三、类关系梳理

1. 主类

这些类封装正则表达式和在字符的目标序列中匹配正则表达式的结果。

1. basic_regex

basic_regex :正则表达式对象

在源代码里面看到那个 std::regex 对象就是用这个 basic_regex 定义的

/** @brief Standard regular expressions. */
typedef basic_regex<char>    regex;

sub_match :标识子表达式所匹配的字符序列

match_results:标识一个正则表达式匹配,包含所有子表达式匹配

2. 算法

这些算法将封装于 regex 的正则表达式应用到字符的目标序列。

1. regex_match

regex_match:尝试匹配一个正则表达式到整个字符序列

2. regex_search

regex_search:尝试匹配一个正则表达式到字符序列的任何部分

3. regex_replace

regex_replace:以格式化的替换文本来替换正则表达式匹配的出现位置

3. 迭代器

regex_iterator:用于遍历在序列中找到的匹配正则表达式的整个集合。

regex_iterator :迭代一个字符序列中的所有正则表达式匹配

regex_token_iterator:迭代给定字符串中的所有正则表达式匹配中的指定子表达式,或迭代未匹配的子字符串

4. 异常

此类定义作为异常抛出以报告来自正则表达式库错误的类型。

regex_error :报告正则表达式库生成的错误信息

在这里插入图片描述

使用这个也是非常简单的

#include <regex>
#include <iostream>
 
int main()
{
    try {
        std::regex re("[a-b][a");
    }
    catch (const std::regex_error& e) {
        std::cout << "regex_error caught: " << e.what() << '\n';
        
        // 这个错误码定义在 6.常量.error_type 中
        if (e.code() == std::regex_constants::error_brack) {
            std::cout << "The code was error_brack\n";
        }
    }
}

// 输出
regex_error caught: The expression contained mismatched [ and ].
The code was error_brack

5. 特征

regex_traits 类用于封装 regex 的本地化方面。

regex_traits:提供正则表达式库所需的关于字符类型的元信息

6. 常量

定义于命名空间 std::regex_constants

1. syntax_option_type

syntax_option_type: 控制正则表达式行为的通用选项,这个参数是放在 regex 对象构造函数中去设置匹配的

就像这种

 std::regex re2(".*(a|xayy)", std::regex::extended);
constexpr syntax_option_type icase = /*unspecified*/;
 
constexpr syntax_option_type nosubs = /*unspecified*/;
constexpr syntax_option_type optimize = /*unspecified*/;
constexpr syntax_option_type collate = /*unspecified*/;
constexpr syntax_option_type ECMAScript = /*unspecified*/;
constexpr syntax_option_type basic = /*unspecified*/;
constexpr syntax_option_type extended = /*unspecified*/;
constexpr syntax_option_type awk = /*unspecified*/;
constexpr syntax_option_type grep = /*unspecified*/;
constexpr syntax_option_type egrep = /*unspecified*/;

解释

效果
icase应当以不考虑大小写进行字符匹配。
nosubs进行匹配时,将所有被标记的子表达式 (expr) 当做非标记的子表达式 (?:expr) 。不将匹配存储于提供的 std::regex_match 结构中,且 mark_count() 为零
optimize指示正则表达式引擎进行更快的匹配,带有令构造变慢的潜在开销。例如这可能表示将非确定 FSA 转换为确定 FSA 。
collate形如 “[a-b]” 的字符范围将对本地环境敏感。
multiline(C++17) 若选择 ECMAScript 引擎,则指定 ^ 应该匹配行首,而 $ 应该匹配行尾。
ECMAScript使用改 ECMAScript 正则表达式文法
basic使用基本 POSIX 正则表达式文法(文法文档)。
extended使用扩展 POSIX 正则表达式文法(文法文档)。
awk使用 POSIX 中 awk 工具所用的正则表达式文法(文法文档)。
grep使用 POSIX 中 grep 工具所用的正则表达式文法。这等效于 basic 选项附带作为另一种分隔符的换行符 ‘\n’ 。
egrep使用 POSIX 中 grep 工具带 -E 选项所用的正则表达式文法。这等效于 extended 附带 ’

ECMAScript, basic, extended, awk, grep, egrep 必须选取至多一个文法选项。若不选取文法选项,则设定为选取 ECMAScript 。其他选项作为修饰符工作,从而 std::regex(“meow”, std::regex::icase) 等价于 std::regex(“meow”, std::regex::ECMAScript|std::regex::icase)

注意
因为 POSIX 使用“最左最长”匹配规则(最长的匹配子序列得到匹配,且若存在数个这种子序列,则匹配最左者),故它不适用的例子之一是剖析标签语言:如 “<tag[^>]>.” 这种 POSIX 正则表达式会匹配从首个 “<tag” 到最末 “” 的任何内容,包含中间的每个 “” 和 “” 。另一方面, ECMAScript 支持非贪心匹配,且 ECMAScript 正则表达式 “<tag[^>]>.?” 会只匹配到首个闭标签。

下面描述 ECMA 和 POSIX 匹配的区别

#include <iostream>
#include <string>
#include <regex>
 
int main()
{
    std::string str = "zzxayyzz";
    std::regex re1(".*(a|xayy)"); // ECMA
    std::regex re2(".*(a|xayy)", std::regex::extended); // POSIX
 
    std::cout << "Searching for .*(a|xayy) in zzxayyzz:\n";
    std::smatch m;
    std::regex_search(str, m, re1);
    std::cout << " ECMA (depth first search) match: " << m[0] << '\n';
    std::regex_search(str, m, re2);
    std::cout << " POSIX (leftmost longest)  match: " << m[0] << '\n';
}

// 输出
Searching for .*(a|xayy) in zzxayyzz:
ECMA (depth first search) match: zzxa
POSIX (leftmost longest)  match: zzxayy

2. match_flag_type

match_flag_type:特定于匹配的选项,这个是用在 regex_match、regex_search、regex_replace 三个算法函数中的一个参数。

就像下面的 regex_match 函数的 flags 是给的默认值

template< class BidirIt,
          class CharT, class Traits >
bool regex_match( BidirIt first, BidirIt last,
                   const std::basic_regex<CharT,Traits>& e,
                   std::regex_constants::match_flag_type flags =
                      std::regex_constants::match_default );
constexpr match_flag_type match_default = {};
 
constexpr match_flag_type match_not_bol = /*unspecified*/;
constexpr match_flag_type match_not_eol = /*unspecified*/;
constexpr match_flag_type match_not_bow = /*unspecified*/;
constexpr match_flag_type match_not_eow = /*unspecified*/;
constexpr match_flag_type match_any = /*unspecified*/;
constexpr match_flag_type match_not_null = /*unspecified*/;
constexpr match_flag_type match_continuous = /*unspecified*/;
constexpr match_flag_type match_prev_avail = /*unspecified*/;
constexpr match_flag_type format_default = {};
constexpr match_flag_type format_sed = /*unspecified*/;
constexpr match_flag_type format_no_copy = /*unspecified*/;

注意: [first, last) 指代要匹配的字符序列。

常量解释
match_not_bol[first,last) 中的首个字符将被处理成如同它不在行首(即 ^ 将不匹配 [first,first) )
match_not_eol[first,last) 中的最末字符将被处理成如同它不在行尾(即 $ 将不匹配 [last,last) )
match_not_bow“\b” 将不匹配 [first,first)
match_not_eow“\b” 将不匹配 [last,last)
match_any若多于一个匹配可行,则任何匹配都是可接受的结果
match_not_null不匹配空字符序列
match_continuous仅匹配始于 first 的子串
match_prev_avail–first 是合法的迭代位置。设置时导致 match_not_bol 和 match_not_bow 被忽略
format_default使用 ECMAScript 规则于 std::regex_replace 构造字符串(语法文档)
format_sed 于std::regex_replace 使用 POSIX sed 工具规则。(语法文档)
format_no_copy不复制不匹配的字符串到 std::regex_replace 中的输出
format_first_only仅替换 std::regex_replace 中的首个匹配

match_defaultformat_default 以外的所有常量都是位掩码元素。 match_defaultformat_default 常量是空位掩码。

3. error_type

error_type:描述不同类型的匹配错误,可以用 try catch 捕获

constexpr error_type error_collate = /*unspecified*/;
constexpr error_type error_ctype = /*unspecified*/;
constexpr error_type error_escape = /*unspecified*/;
constexpr error_type error_backref = /*unspecified*/;
constexpr error_type error_brack = /*unspecified*/;
constexpr error_type error_paren = /*unspecified*/;
constexpr error_type error_brace = /*unspecified*/;
constexpr error_type error_badbrace = /*unspecified*/;
constexpr error_type error_range = /*unspecified*/;
constexpr error_type error_space = /*unspecified*/;
constexpr error_type error_badrepeat = /*unspecified*/;
constexpr error_type error_complexity = /*unspecified*/;
constexpr error_type error_stack = /*unspecified*/;

名词解释如下:

常量解释
error_collate表达式含有非法对照字符名
error_ctype表达式含有非法字符类名
error_escape表达式含有非法转义字符或尾随转义
error_backref表达式含有非法回溯引用
error_brack表达式含有不匹配的方括号对( ‘[’ 与 ‘]’ )
error_paren表达式含有不匹配的括号对( ‘(’ 与 ‘)’ )
error_brace表达式含有不匹配的花括号对( ‘{’ 与 ‘}’ )
error_badbrace表达式在 {} 表达式中含有非法范围
error_range表达式含有非法字符范围(例如 [b-a] )
error_space没有将表达式转换成有限状态机的足够内存
error_badrepeat*?+{ 之一不后继一个合法正则表达式
error_complexity尝试的匹配的复杂度超过了预定义的等级
error_stack没有进行匹配的足够内存

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1400685.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

6.3.5编辑视频

6.3.5编辑视频 除了上面的功能外&#xff0c;Camtasia4还能进行简单的视频编辑工作&#xff0c;如媒体的剪辑、连接、画中画等。 下面我们就利用Camtasia4的强大功能来实现一个画中画效果&#xff0c;在具体操作之前&#xff0c;需要准备好两个视频文件&#xff0c;一个作为主…

C++:练习:类的一些简单例题(学习编程的前期需要大量的读和写基本C++代码)

2014年1月21日 内容整理自《程序设计教程&#xff1a;用C语言编程 第三版》 陈家骏 郑滔 --------------------------------------------------------------------------------------------------------------------------------- 例题1&#xff1a;用类来实现“栈”这一数…

(二十三)Kubernetes系列之prometheus+grafana安装

1.kube-prometheus安装 1.1 下载 访问地址&#xff1a;https://github.com/prometheus-operator/kube-prometheus/releases 点击Source code (tar.gz)进行下载&#xff0c;并上传到k8s服务器master节点 1.2解压 tar zxvf kube-prometheus-0.11.0.tar.gz 1.3进入kube-prome…

2024年黑龙江事业单位招聘报名详细流程图解,千万不要错过报名哦

⭐报名入口&#xff1a;入黑龙江省事业单位公开招聘服务平台 ✅报名时间&#xff1a;2024年1月22日9:00-1月26日17:00 ✅笔试联考&#xff1a;2024年3月30日 报名流程如下&#xff0c;具体可查看笔记详细图解 第一步&#xff0c;注册及登录&#xff0c;新用户注册新账号。 第二…

【数据结构】单链表的基本操作 (C语言版)

目录 一、单链表 1、单链表的定义&#xff1a; 2、单链表的优缺点&#xff1a; 二、单链表的基本操作算法&#xff08;C语言&#xff09; 1、宏定义 2、创建结构体 3、初始化 4、插入 4、求长度 5、清空 6、销毁 7、取值 8、查找 9、删除 10、头插法创建单链表…

Centos使用Docker搭建自己的Gitlab(社区版和设置汉化、修改密码、设置SSH秘钥、添加拉取命令端口号)

根据我的经验 部署Gitlab&#xff08;社区版&#xff09; 至少需要2核4g的服务器 带宽3~4M 1. 在自己电脑上安装终端&#xff1a;宝塔ssl终端 或者 FinalShell&#xff0c;根据喜好安装即可 http://www.hostbuf.com/t/988.html http://www.hostbuf.com/downloads/finalshell_w…

xshell配置隧道转移规则

钢铁知识库&#xff0c;一个学习python爬虫、数据分析的知识库。人生苦短&#xff0c;快用python。 xshell是什么 通俗点说就是一款强大ssh远程软件&#xff0c;可以方便运维人员对服务器进行管理操作&#xff0c;功能很多朋友们自行探索&#xff0c;今天只聊其中一个功能点那…

中仕教育:研究生毕业可以考选调生吗?

选调生的报考条件之一是应届生&#xff0c;研究生毕业也属于应届生&#xff0c;所以是可以报考的。 选调生不同学历的年龄限制&#xff1a; 1.应届本科生&#xff1a;年龄在25岁以内 2.应届研究生&#xff1a;年龄在30岁以内 3.应届博士生&#xff1a;年龄在35岁以内 研究…

如何为不同品牌的笔记本电脑设置充电限制,这里提供详细步骤

笔记本电脑的电池健康状况至关重要。延长电池寿命可以帮你省下不少钱。对于长时间充电的Windows 11笔记本电脑用户来说,将电池电量限制在80%是很重要的。 虽然操作系统没有提供设置自定义电池充电限制的内置方法,但仍有一些方法可以在Windows 11中配置电池设置,并将其限制在…

kafka(一)——简介

简介 Kafka 是一种分布式、支持分区、多副本的消息中间件&#xff0c;支持发布-订阅模式&#xff0c;多用于实时处理大量数据缓存的场景&#xff0c;类似于一个“缓存池”。 架构 Producer&#xff1a;消息生产者&#xff1b;Consumer&#xff1a;消息消费者&#xff1b;Brok…

6. Spring Boot的starters

6. Spring Boot的starters(重要) 一般认为&#xff0c;SpringBoot 微框架从两个主要层面影响 Spring 社区的开发者们&#xff1a; 基于 Spring 框架的“约定优先于配置&#xff08;COC&#xff09;”理念以及最佳实践之路。提供了针对日常企业应用研发各种场景的 spring-boot…

人工智能原理实验2(2)——罗马尼亚问题(贪婪搜索、A*搜索、BFS、DFS)

&#x1f9e1;&#x1f9e1;实验内容&#x1f9e1;&#x1f9e1; 根据上图以Zerind为初始状态&#xff0c;Bucharest为目标状态实现搜索&#xff0c;分别以贪婪搜索&#xff08;只考虑直线距离&#xff09;和A算法求解最短路径。 按顺序列出贪婪算法探索的扩展节点和其估价函数…

读书笔记-《数据结构与算法》-摘要8[桶排序]

桶排序和归并排序有那么点点类似&#xff0c;也使用了归并的思想。大致步骤如下&#xff1a; 设置一个定量的数组当作空桶。Divide - 从待排序数组中取出元素&#xff0c;将元素按照一定的规则塞进对应的桶子去。对每个非空桶进行排序&#xff0c;通常可在塞元素入桶时进行插入…

springboot113健身房管理系统

简介 【毕设源码推荐 javaweb 项目】基于springbootvue 的健身房管理系统 适用于计算机类毕业设计&#xff0c;课程设计参考与学习用途。仅供学习参考&#xff0c; 不得用于商业或者非法用途&#xff0c;否则&#xff0c;一切后果请用户自负。 看运行截图看 第五章 第四章 获取…

文件操作和IO(1)

认识文件 先来认识狭义上的文件(存储在硬盘(磁盘)上).针对硬盘这种持久化的I/O设备,当我们想要进行数据保存时,往往不是保存成一个整体,而是独立成一个个的单位进行保存,这个独立的单位就被抽象成文件的概念,就类似办公桌上的一份份真实的文件一般. 注意:硬盘 ! 磁盘 磁盘属于…

【算法与数据结构】1049、LeetCode 最后一块石头的重量 II

文章目录 一、题目二、解法三、完整代码 所有的LeetCode题解索引&#xff0c;可以看这篇文章——【算法和数据结构】LeetCode题解。 一、题目 二、解法 思路分析&#xff1a;本题需要得到石头之间两两粉碎之后的最小值&#xff0c;那么一个简单的思路就是将这堆石头划分成大小相…

HDFS节点故障的容错方案

HDFS节点故障的容错方案 1. NN高可用1.1 选主逻辑1.2 HA切换1.3 注意点1.3.1 fencing的处理1.3.2 健康状态的定义1.3.3 确保zk中的父节点存在1.3.4 确保NN的ID与IP保持一致 2. DN高可用2.1 感知DN节点异常2.1.1 NN感知DN心跳超时2.1.1 客户端链接DN异常 2.2 异常DN上的数据处理…

6.4.4释放音频

6.4.4释放音频 许多Flash动画里的音乐或歌曲非常好听&#xff0c;能不能在没有源文件的情况下把里面的声音文件取出来呢&#xff1f;利用Swf2VideoConverter2可以轻松做到这一点。 1&#xff0e;单击“添加”按钮&#xff0c;在弹出的下拉菜单中选择“添加文件”&#xff0c;…

蓝桥备战--分糖果OJ2928 贪心 分类讨论

题目&#xff1a; 思路&#xff1a; 首先排序(经验之谈) 分类讨论 我们要做到不重不漏的分类 代码&#xff1a; #include <iostream> #include <algorithm> using namespace std;const int N 1e6 10;char dist[N]; int n, x;int main() {string str;cin >…

以超市数据微案例-fineBI可视化分析

一、入门案例&#xff1a; 2.分析思路&#xff1a; 数据清晰界面中添加毛利额计算 **所以在新增步骤之后&#xff0c;必须点击保存并更新&#xff0c;否则可视化界面中无法使用最新的数据 4、数据可视化分析 1&#xff09;销售额最高的十大商品种类 为1-8月超市数据&#xff…