使用正则表达式的C++程序打印每个单词的首字母
A useful tool for string operations is regex. This may be found in virtually all high-level 当前的编程语言,包括C++。正则表达式(Regex)被用作 通用搜索模式。例如,通过构建一个简单的字符串 被称为正则表达式,我们可以使用至少实现密码验证逻辑 一个大写字母,一个小写字母,一个数字,一个特殊字符,并且总长度至少为 8个字符。
In this tutorial, we'll look at how to use C++ to display only the first letters of words included 在指定的字符串内。在这里,我们将看一个使用空格来分隔单词的句子 无论字符是大写还是小写,计算机都会读取 将字符串使用正则表达式分割,并返回每个单词的第一个字符。
To use regular expressions, we need to import the regex library using the ‘regex’ header. To 使用正则表达式,我们需要以下语法 -
语法(创建正则表达式对象)
regex obj_name( ) 登录后复制