txt 2 re
knowing is obsolete :: regular expression generator (perl php python java javascript coldfusion c c++ ruby vb vbscript j# c# c++.net vb.net)
 
 
 
Enter the string that you want to use a regular expression on:
1
   
 
Select the elements that you want to extract to run regular expression generator:
2
1
c 1
d1
1
c 1
d1
day11
11
:
c :
J
c J
wJ
u
c u
wu
l
c l
wl
varJul
wordJul
monthJul
:
c :
2
c 2
d2
0
c 0
d0
1
c 1
d1
8
c 8
d8
day18
year2018
int2018
ddmmmyyyy11:Jul:2018
_
c _
ws_
"
c "
T
c T
wT
h
c h
wh
i
c i
wi
s
c s
ws
varThis
wordThis
_
c _
ws_
i
c i
wi
s
c s
ws
varis
wordis
_
c _
ws_
a
c a
wa
n
c n
wn
varan
wordan
_
c _
ws_
E
c E
wE
x
c x
wx
a
c a
wa
m
c 
wm
p
c p
wp
l
c l
wl
e
c e
we
varExample
wordExample
!
c !
"
c "
string"This_is_an_Example!"
< Source String
What to click?  extract any integer in this position
extract this integer (2006) in this position
 
3C++ regular expression program that extracts the selected elements from the entered string:
Perl PHP Python Java Javascript ColdFusion C [C++] Ruby VB VBScript J#.net C#.net C++.net VB.net 
 
// URL that generated this code:
// http://txt2re.com/index-c++.php3?s=11:Jul:2018%20%22This%20is%20an%20Example!%22&73&-12

#include <stdlib.h>
#include <string>
#include <iostream>
#include <pme.h>

int main()
{
  std::string txt="11:Jul:2018 \"This is an Example!\"";

  std::string re1="(11)";	// Integer Number 1
  std::string re2=".*?";	// Non-greedy match on filler
  std::string re3=".";	// Uninteresting: c
  std::string re4=".*?";	// Non-greedy match on filler
  std::string re5=".";	// Uninteresting: c
  std::string re6=".*?";	// Non-greedy match on filler
  std::string re7=".";	// Uninteresting: c
  std::string re8=".*?";	// Non-greedy match on filler
  std::string re9=".";	// Uninteresting: c
  std::string re10=".*?";	// Non-greedy match on filler
  std::string re11=".";	// Uninteresting: c
  std::string re12=".*?";	// Non-greedy match on filler
  std::string re13=".";	// Uninteresting: c
  std::string re14=".*?";	// Non-greedy match on filler
  std::string re15=".";	// Uninteresting: c
  std::string re16=".*?";	// Non-greedy match on filler
  std::string re17=".";	// Uninteresting: c
  std::string re18=".*?";	// Non-greedy match on filler
  std::string re19=".";	// Uninteresting: c
  std::string re20=".*?";	// Non-greedy match on filler
  std::string re21=".";	// Uninteresting: c
  std::string re22=".*?";	// Non-greedy match on filler
  std::string re23=".";	// Uninteresting: c
  std::string re24=".*?";	// Non-greedy match on filler
  std::string re25=".";	// Uninteresting: c
  std::string re26=".*?";	// Non-greedy match on filler
  std::string re27=".";	// Uninteresting: c
  std::string re28=".*?";	// Non-greedy match on filler
  std::string re29=".";	// Uninteresting: c
  std::string re30=".*?";	// Non-greedy match on filler
  std::string re31=".";	// Uninteresting: c
  std::string re32=".*?";	// Non-greedy match on filler
  std::string re33=".";	// Uninteresting: c
  std::string re34=".*?";	// Non-greedy match on filler
  std::string re35=".";	// Uninteresting: c
  std::string re36=".*?";	// Non-greedy match on filler
  std::string re37=".";	// Uninteresting: c
  std::string re38=".*?";	// Non-greedy match on filler
  std::string re39=".";	// Uninteresting: c
  std::string re40=".*?";	// Non-greedy match on filler
  std::string re41=".";	// Uninteresting: c
  std::string re42=".*?";	// Non-greedy match on filler
  std::string re43=".";	// Uninteresting: c
  std::string re44=".*?";	// Non-greedy match on filler
  std::string re45=".";	// Uninteresting: c
  std::string re46=".*?";	// Non-greedy match on filler
  std::string re47=".";	// Uninteresting: c
  std::string re48=".*?";	// Non-greedy match on filler
  std::string re49=".";	// Uninteresting: c
  std::string re50=".*?";	// Non-greedy match on filler
  std::string re51=".";	// Uninteresting: c
  std::string re52=".*?";	// Non-greedy match on filler
  std::string re53="(.)";	// Any Single Character 1

  PME re(re1+re2+re3+re4+re5+re6+re7+re8+re9+re10+re11+re12+re13+re14+re15+re16+re17+re18+re19+re20+re21+re22+re23+re24+re25+re26+re27+re28+re29+re30+re31+re32+re33+re34+re35+re36+re37+re38+re39+re40+re41+re42+re43+re44+re45+re46+re47+re48+re49+re50+re51+re52+re53,"gims");
  int n;
  if ((n=re.match(txt))>0)
  {
      std::string int1=re[1].c_str();
      std::string c1=re[2].c_str();
      std::cout << "("<<int1<<")"<<"("<<c1<<")"<< std::endl;
  }
}

//-----
// C++ does not provide a regular expression feature as standard.
//
// To run this code you will need to first download and install
// the PCRE library from http://www.pcre.org/ and 
// the PME library from ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/Contrib/
// 
// Note that on Linux systems PCRE is often already installed in /usr/lib/libpcre* or /usr/local/lib/libpcre*. 
//
// Compile and run on Unix using 
// # c++ x.cpp -lpme -lpcre 
// # ./a.out
// 
 
 
  home     faq              ©2006 mark james ennis