The GRETA Regular Expression Template Archive

简介:      The regular expression template library contains objects and functions that make it possibl...
     The regular expression template library contains objects and functions that make it possible to perform pattern matching and substitution on strings in C++.  They are:
        rpattern: the pattern to use during the search.
        match_results/subst_results: container for the results of a match/substitution.
    To perform a search or replace operation, you will typically first initialize an rpattern object by giving it a string representing the pattern against which to match.  You will then call a method on the rpattern object (match() or substitute(), for instance), passing it a string to match against and a match_results objects to receive the results of the match.  If the match()/substitute() fails, the method returns false.  If it succeeds, it returns true, and the match_results object stores the resulting array of backreferences internally.  (Here, the term backreference has the same meaning as it does in Perl.  Backreferences provide extra information about what parts of the pattern matched which parts of the string.)  There are methods on the match_results object to make the backreference information available.  For example:
 
#include <iostream>
#include <string>
#include “regexpr2.h”
using namespace std;
using namespace regex;
 
int main() {
    match_results results;
    string str( “The book cost $12.34” );
    rpattern pat( “//$(//d+)(//.(//d//d))?” ); 
    // Match a dollar sign followed by one or more digits,
    // optionally followed by a period and two more digits.
    // The double-escapes are necessary to satisfy the compiler.
 
    match_results::backref_type br = pat.match( str, results );
    if( br.matched ) {
        cout << “match success!” << endl;
        cout << “price: ” << br << endl;
    } else {
        cout << “match failed!” << endl;
    }
    return 0;
}
 
    The above program would print out the following:
         match success!
         price: $12.34
 
    The following sections discuss the rpattern object in detail and how to customize your searches to be faster and more efficient.
 
     Note: all declarations in the header file (regexpr2.h) are contained in the regex namespace.  To use any of the objects, methods or enumerations described in this document, you must prepend all declarations with “regex::” or you must have the “using namespace regex;” directive somewhere within the enclosing scope of your declarations.  For simplicity, I’ve left off the “regex::” prefixes in the rest of my code snippets.
目录
相关文章
|
计算机视觉
使用计算机视觉实战项目精通 OpenCV:1~5
使用计算机视觉实战项目精通 OpenCV:1~5
516 0
|
存储 安全 算法
一文理解UDS安全访问服务(0x27)
一文理解UDS安全访问服务(0x27)
一文理解UDS安全访问服务(0x27)
|
4月前
|
运维 Prometheus 监控
别再盲选了!开源运维工具选型这事儿,咱得说人话
别再盲选了!开源运维工具选型这事儿,咱得说人话
261 7
|
6月前
|
存储 算法 调度
|
8月前
|
人工智能 数据库管理 OLAP
Qwen3 + AnalyticDB+Dify on DMS 私有部署指导⽂档
Qwen3 + AnalyticDB+Dify on DMS 私有部署指导⽂档
2148 2
|
8月前
|
存储 前端开发 JavaScript
69.9K star!这个API调试神器让你告别Postman,开源免费真香!
Hoppscotch 是一款专为开发者打造的轻量级API调试工具,凭借其极简的界面设计和强大的功能支持,已成为GitHub上最受欢迎的API开发工具之一。无需安装客户端,打开浏览器即可享受媲美Postman的专业体验!
362 0
|
JavaScript 前端开发 Java
Github 2024-08-01 开源项目月报 Top17
根据Github Trendings统计,2024年8月共有17个项目上榜。按开发语言分类,项目数量如下:Python项目6个,非开发语言项目与TypeScript项目各4个,JavaScript项目3个,Java、Go及Vue项目各1个。其中,免费编程学习平台freeCodeCamp.org以381,011个Star数领先,提供全栈网页开发和机器学习课程。其他项目涵盖编程书籍、API集合、低代码开发平台等多种资源。
313 1
|
应用服务中间件 网络安全 nginx
使用Nginx Proxy Manager配置Halo的反向代理和申请 SSL 证书
本文引导如何用Nginx Proxy Manager (NPM)配置Halo的反向代理与SSL证书。NPM简化了Nginx的配置流程,适合无Nginx基础的用户。安装NPM无需额外安装Nginx,避免端口冲突。通过`docker-compose.yaml`启动NPM服务,并映射必要的端口。配置Halo反向代理需登录NPM面板,添加代理主机,设置域名、转发IP等参数。NPM支持自动申请与续期SSL证书,确保网站安全访问。更多Halo安装细节,请参考[如何在Linux云服务器上通过Docker Compose部署安装Halo](https://zhangfeidezhu.com/?p=631).
922 0
使用Nginx Proxy Manager配置Halo的反向代理和申请 SSL 证书
|
安全 网络协议 网络安全
网络安全行业黑话大全
网络安全行业黑话大全
568 1
|
算法 安全
秒懂算法 | 银行家算法
最具有代表性的避免死锁的算法是Dijkstra的银行家算法,由于该算法可能用于银行现金贷款而得名。一个银行家把他的固定资金贷给若干顾客,只要不出现一个顾客借走所有资金后还不够,银行家的资金应是安全的。银行家需要一个算法保证借出去的资金在有限时间内可以收回。 假定顾客分成若干次进行贷款,并在第一次贷款时说明他的最大借款额。具体算法如下:
563 0
秒懂算法 | 银行家算法