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
4
c 4
d4
2
c 
d2
day2
int42
_
c _
ws
4
c 4
d4
3
c 3
d3
day3
int
< 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=42%2043&2&11&5

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

int main()
{
  std::string txt="42 43";

  std::string re1=".*?";	// Non-greedy match on filler
  std::string re2=".";	// Uninteresting: c
  std::string re3="(.)";	// Any Single Character 1
  std::string re4="(\\s+)";	// White Space 1
  std::string re5="(\\d+)";	// Integer Number 1

  PME re(re1+re2+re3+re4+re5,"gims");
  int n;
  if ((n=re.match(txt))>0)
  {
      std::string c1=re[1].c_str();
      std::string ws1=re[2].c_str();
      std::string int1=re[3].c_str();
      std::cout << "("<<c1<<")"<<"("<<ws1<<")"<<"("<<int1<<")"<< 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
// 
 
 
 
 
Feedback
::  Fri, 10 Oct 2014 01:40PM
Андрей Викторович::  Fri, 10 Oct 2014 03:53PM
::  Fri, 10 Oct 2014 03:56PM
CVirus:: life saviorSat, 11 Oct 2014 08:13PM
Mintpal-JRWR:: Amazing Tooll, Never not use this tool!Sat, 11 Oct 2014 08:22PM
observer:: Really really really amazing toooool. thank you very muchSun, 12 Oct 2014 12:29PM
Андрей Викторович::  Mon, 13 Oct 2014 08:21AM
::  Mon, 13 Oct 2014 08:47AM
regexxer:: Great , thx dude you are number oneMon, 13 Oct 2014 09:05AM
::  Mon, 13 Oct 2014 02:03PM
:: Works perfect with python.. Thanks to Dev team.Tue, 14 Oct 2014 01:57PM
Vivek Sharma:: Works perfect with python.. Thanks to Dev team.Tue, 14 Oct 2014 01:58PM
::  Tue, 14 Oct 2014 02:08PM
::  Tue, 14 Oct 2014 03:28PM
Hallo:: PommesTue, 14 Oct 2014 04:32PM
Hi:: Was able to drop it into notepad++'s regex search, thanks !Tue, 14 Oct 2014 09:24PM
Jo:: Thanks a lot!! It's very useful.Wed, 15 Oct 2014 03:55AM
Me:: i can't find phone number :/Wed, 15 Oct 2014 02:53PM
::  Thu, 16 Oct 2014 07:51AM
:: ddsaFri, 17 Oct 2014 02:25AM
:: i can,t find img urlFri, 17 Oct 2014 02:26AM
::  Fri, 17 Oct 2014 03:22AM
Андрей Викторович::  Fri, 17 Oct 2014 04:40PM
G.Uzunov:: Thanks, very intuitive and usefulSat, 18 Oct 2014 09:27AM
::  Sat, 18 Oct 2014 11:01AM
::  Sat, 18 Oct 2014 11:01AM
baboomerang:: thanks alot dude! Such a life saverMon, 20 Oct 2014 02:37AM
::  Mon, 20 Oct 2014 04:36AM
:: in the example "14:18:30 and 13 rooms" the num 13 room doesnt becomes int '13' because of time has hour hh greater than 12 . can some one helpTue, 21 Oct 2014 02:52AM
::  Tue, 21 Oct 2014 11:52AM
:: this site has saved me so much time for years, i'd be in trouble if it ever went away, thank youTue, 21 Oct 2014 06:45PM
:: Very useful. Would it also be possible to support regexes for (1) unix/linux utilities sed and grep and (2) Visual studio regexes?Tue, 21 Oct 2014 09:18PM
:: Feature request: Allow user to supply a list of strings, and for txt2re to generate a single regex that would match them all. Thanks,Tue, 21 Oct 2014 09:22PM
:: Feature request: Allow user to supply a list of strings, and for txt2re to generate a single regex that would match them all. Thanks,Tue, 21 Oct 2014 09:28PM
::  Wed, 22 Oct 2014 08:07AM
::  Wed, 22 Oct 2014 01:52PM
Jamie:: Thank you! Great tool. I forgot even the basics of regex and this tool helped me out.Wed, 22 Oct 2014 03:03PM
Anon:: Fucking awesome.Wed, 22 Oct 2014 04:48PM
:: 1 OR 1=1Wed, 22 Oct 2014 11:13PM
::  Thu, 23 Oct 2014 01:46PM
::  Thu, 23 Oct 2014 05:21PM
::  Fri, 24 Oct 2014 02:49AM
::  Fri, 24 Oct 2014 07:09AM
::  Fri, 24 Oct 2014 09:52AM
 
  home     faq              ©2006 mark james ennis