forked from boostorg/regex
Updated regex examples and Jamfiles so that they are run as tests.
[SVN r12149]
This commit is contained in:
@ -1,24 +1,28 @@
|
||||
subproject libs/regex/example ;
|
||||
|
||||
|
||||
exe timer : timer/regex_timer.cpp
|
||||
unit-test timer : timer/regex_timer.cpp
|
||||
<lib>../build/libboost_regex$(SUFLIB)
|
||||
:
|
||||
<include>../../../
|
||||
<define>BOOST_REGEX_NO_LIB=1
|
||||
<define>BOOST_REGEX_STATIC_LINK=1
|
||||
:
|
||||
debug
|
||||
release
|
||||
:
|
||||
timer/input_script.txt
|
||||
;
|
||||
|
||||
exe jgrep : jgrep/jgrep.cpp jgrep/main.cpp
|
||||
unit-test jgrep : jgrep/jgrep.cpp jgrep/main.cpp
|
||||
<lib>../build/libboost_regex$(SUFLIB)
|
||||
:
|
||||
<include>../../../
|
||||
<define>BOOST_REGEX_NO_LIB=1
|
||||
<define>BOOST_REGEX_STATIC_LINK=1
|
||||
:
|
||||
debug
|
||||
release
|
||||
:
|
||||
-n boost/ ../../../boost/regex.hpp
|
||||
;
|
||||
|
||||
unit-test credit_card_example : snippets/credit_card_example.cpp
|
||||
@ -44,7 +48,7 @@ unit-test partial_regex_grep : snippets/partial_regex_grep.cpp
|
||||
../index.htm
|
||||
;
|
||||
|
||||
exe partial_regex_match : snippets/partial_regex_match.cpp
|
||||
unit-test partial_regex_match : snippets/partial_regex_match.cpp
|
||||
<lib>../build/libboost_regex$(SUFLIB)
|
||||
:
|
||||
<include>../../../
|
||||
@ -52,6 +56,8 @@ exe partial_regex_match : snippets/partial_regex_match.cpp
|
||||
<define>BOOST_REGEX_STATIC_LINK=1
|
||||
:
|
||||
debug
|
||||
:
|
||||
1234-5678-8765-4
|
||||
;
|
||||
|
||||
unit-test regex_grep_example_1 : snippets/regex_grep_example_1.cpp
|
||||
@ -102,7 +108,7 @@ unit-test regex_grep_example_4 : snippets/regex_grep_example_4.cpp
|
||||
../../../boost/smart_ptr.hpp
|
||||
;
|
||||
|
||||
exe regex_match_example : snippets/regex_match_example.cpp
|
||||
unit-test regex_match_example : snippets/regex_match_example.cpp
|
||||
<lib>../build/libboost_regex$(SUFLIB)
|
||||
:
|
||||
<include>../../../
|
||||
@ -110,6 +116,8 @@ exe regex_match_example : snippets/regex_match_example.cpp
|
||||
<define>BOOST_REGEX_STATIC_LINK=1
|
||||
:
|
||||
debug
|
||||
:
|
||||
-auto
|
||||
;
|
||||
|
||||
unit-test regex_merge_example : snippets/regex_merge_example.cpp
|
||||
@ -136,7 +144,7 @@ unit-test regex_search_example : snippets/regex_search_example.cpp
|
||||
../../../boost/smart_ptr.hpp
|
||||
;
|
||||
|
||||
exe regex_split_example_1 : snippets/regex_split_example_1.cpp
|
||||
unit-test regex_split_example_1 : snippets/regex_split_example_1.cpp
|
||||
<lib>../build/libboost_regex$(SUFLIB)
|
||||
:
|
||||
<include>../../../
|
||||
@ -144,6 +152,8 @@ exe regex_split_example_1 : snippets/regex_split_example_1.cpp
|
||||
<define>BOOST_REGEX_STATIC_LINK=1
|
||||
:
|
||||
debug
|
||||
:
|
||||
-auto
|
||||
;
|
||||
|
||||
unit-test regex_split_example_2 : snippets/regex_split_example_2.cpp
|
||||
@ -164,3 +174,4 @@ unit-test regex_split_example_2 : snippets/regex_split_example_2.cpp
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -29,7 +29,10 @@ int main(int argc, char* argv[])
|
||||
{
|
||||
try{
|
||||
std::string input;
|
||||
std::cin >> input;
|
||||
if(argc > 1)
|
||||
input = argv[1];
|
||||
else
|
||||
std::cin >> input;
|
||||
if(is_possible_card_number(input))
|
||||
{
|
||||
std::cout << "Matched OK..." << std::endl;
|
||||
|
@ -68,30 +68,35 @@ istream& getline(istream& is, std::string& s)
|
||||
}
|
||||
#endif
|
||||
|
||||
int main()
|
||||
int main(int argc)
|
||||
{
|
||||
std::string in, out;
|
||||
while(true)
|
||||
{
|
||||
cout << "enter test string" << endl;
|
||||
getline(cin, in);
|
||||
if(in == "quit")
|
||||
break;
|
||||
int result;
|
||||
result = process_ftp(in.c_str(), &out);
|
||||
if(result != -1)
|
||||
{
|
||||
cout << "Match found:" << endl;
|
||||
cout << "Response code: " << result << endl;
|
||||
cout << "Message text: " << out << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
cout << "Match not found" << endl;
|
||||
}
|
||||
cout << endl;
|
||||
}
|
||||
return 0;
|
||||
std::string in, out;
|
||||
do
|
||||
{
|
||||
if(argc == 1)
|
||||
{
|
||||
cout << "enter test string" << endl;
|
||||
getline(cin, in);
|
||||
if(in == "quit")
|
||||
break;
|
||||
}
|
||||
else
|
||||
in = "100 this is an ftp message text";
|
||||
int result;
|
||||
result = process_ftp(in.c_str(), &out);
|
||||
if(result != -1)
|
||||
{
|
||||
cout << "Match found:" << endl;
|
||||
cout << "Response code: " << result << endl;
|
||||
cout << "Message text: " << out << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
cout << "Match not found" << endl;
|
||||
}
|
||||
cout << endl;
|
||||
} while(argc == 1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -51,14 +51,19 @@ istream& getline(istream& is, std::string& s)
|
||||
#endif
|
||||
|
||||
|
||||
int main()
|
||||
int main(int argc)
|
||||
{
|
||||
string s;
|
||||
list<string> l;
|
||||
do{
|
||||
cout << "Enter text to split (or \"quit\" to exit): ";
|
||||
getline(cin, s);
|
||||
if(s == "quit") break;
|
||||
if(argc == 1)
|
||||
{
|
||||
cout << "Enter text to split (or \"quit\" to exit): ";
|
||||
getline(cin, s);
|
||||
if(s == "quit") break;
|
||||
}
|
||||
else
|
||||
s = "This is a string of tokens";
|
||||
unsigned result = tokenise(l, s);
|
||||
cout << result << " tokens found" << endl;
|
||||
cout << "The remaining text is: \"" << s << "\"" << endl;
|
||||
@ -68,6 +73,6 @@ int main()
|
||||
l.pop_front();
|
||||
cout << s << endl;
|
||||
}
|
||||
}while(true);
|
||||
}while(argc == 1);
|
||||
return 0;
|
||||
}
|
||||
|
7
example/timer/input_script.txt
Normal file
7
example/timer/input_script.txt
Normal file
@ -0,0 +1,7 @@
|
||||
abc
|
||||
aaaaaaaaaaabcccccccc
|
||||
quit
|
||||
^([0-9]+)(\-| |$)(.*)$
|
||||
100- this is a line of ftp response which contains a message string
|
||||
quit
|
||||
quit
|
@ -15,14 +15,18 @@
|
||||
|
||||
#ifdef BOOST_RE_OLD_IOSTREAM
|
||||
#include <iostream.h>
|
||||
#include <fstream.h>
|
||||
#else
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
using std::cout;
|
||||
using std::cin;
|
||||
using std::cerr;
|
||||
using std::istream;
|
||||
using std::ostream;
|
||||
using std::endl;
|
||||
using std::ifstream;
|
||||
using std::streambuf;
|
||||
#endif
|
||||
|
||||
#include <algorithm>
|
||||
@ -87,8 +91,21 @@ istream& getline(istream& is, std::string& s)
|
||||
#endif
|
||||
|
||||
|
||||
int main()
|
||||
int main(int argc, char**argv)
|
||||
{
|
||||
ifstream ifs;
|
||||
streambuf* pbuf = 0;
|
||||
if(argc == 2)
|
||||
{
|
||||
ifs.open(argv[1]);
|
||||
if(ifs.bad())
|
||||
{
|
||||
cout << "Bad filename: " << argv[1] << endl;
|
||||
return -1;
|
||||
}
|
||||
pbuf = cin.rdbuf(ifs.rdbuf());
|
||||
}
|
||||
|
||||
boost::regex ex;
|
||||
boost::match_results<std::string::const_iterator> sm;
|
||||
#ifndef BOOST_NO_WREGEX
|
||||
@ -111,6 +128,8 @@ int main()
|
||||
{
|
||||
cout << "Enter expression (or \"quit\" to exit): ";
|
||||
getline(cin, s1);
|
||||
if(argc == 2)
|
||||
cout << endl << s1 << endl;
|
||||
if(s1 == "quit")
|
||||
break;
|
||||
#ifndef BOOST_NO_WREGEX
|
||||
@ -143,6 +162,8 @@ int main()
|
||||
{
|
||||
cout << "Enter string to search (or \"quit\" to exit): ";
|
||||
getline(cin, s2);
|
||||
if(argc == 2)
|
||||
cout << endl << s2 << endl;
|
||||
if(s2 == "quit")
|
||||
break;
|
||||
|
||||
@ -313,6 +334,10 @@ int main()
|
||||
}
|
||||
regfree(&r);
|
||||
}
|
||||
|
||||
if(pbuf)
|
||||
cin.rdbuf(pbuf);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user