1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2025-02-01 02:17:14 +01:00
Sandu Liviu Catalin 4a6bfc086c Major plugin refactor and cleanup.
Switched to POCO library for unified platform/library interface.
Deprecated the external module API. It was creating more problems than solving.
Removed most built-in libraries in favor of system libraries for easier maintenance.
Cleaned and secured code with help from static analyzers.
2021-01-30 08:51:39 +02:00

62 lines
1.0 KiB
C++

//
// grep.cpp
//
// This sample demonstrates the RegularExpression class.
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "Poco/RegularExpression.h"
#include <iostream>
using Poco::RegularExpression;
int main(int argc, char** argv)
{
if (argc < 2)
{
std::cout << "usage: " << argv[0] << ": [-i] [-x] pattern" << std::endl;
return 1;
}
std::string pattern;
int options = 0;
for (int i = 1; i < argc; ++i)
{
std::string arg(argv[i]);
if (arg == "-i")
options += RegularExpression::RE_CASELESS;
else if (arg == "-x")
options += RegularExpression::RE_EXTENDED;
else
pattern = arg;
}
RegularExpression re(pattern, options);
int c = std::cin.get();
while (c != -1)
{
std::string line;
while (c != -1 && c != '\n')
{
line += (char) c;
c = std::cin.get();
}
RegularExpression::Match mtch;
if (re.match(line, mtch))
std::cout << line << std::endl;
if (c != -1) c = std::cin.get();
}
return 0;
}