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 2
d2
day2
int42
_
c _
ws_
4
c 4
d4
3
c 3
d3
day3
int43
< 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-cpcre.php3?s=42%2043&2&3&9999

#include <stdio.h>
#include <string.h>
#include <pcre.h>

int main(int argc, char **argv)
{
  const char *error;
  int erroffset;
  int ovector[186];
  char re[8192]="";
  char txt[]="42 43";

  char re1[]="";	//  1
  strcat(re,re1);
  char re2[]=".*?";	// Non-greedy match on filler
  strcat(re,re2);
  char re3[]="(?:(?:[0-2]?\\d{1})|(?:[3][01]{1}))(?![\\d])";	// Uninteresting: day
  strcat(re,re3);
  char re4[]="((?:(?:[0-2]?\\d{1})|(?:[3][01]{1})))(?![\\d])";	// Day 1
  strcat(re,re4);
  char re5[]=".*?";	// Non-greedy match on filler
  strcat(re,re5);
  char re6[]="(\\d+)";	// Integer Number 1
  strcat(re,re6);

  pcre *r =  pcre_compile(re, PCRE_CASELESS|PCRE_DOTALL, &error, &erroffset, NULL);
  int rc = pcre_exec(r, NULL, txt, strlen(txt), 0, 0, ovector, 186);
  if (rc>0)
  {
      char 1[1024];
      pcre_copy_substring(txt, ovector, rc,1,1, 1024);
      printf("(%s)",1);
      char day1[1024];
      pcre_copy_substring(txt, ovector, rc,2,day1, 1024);
      printf("(%s)",day1);
      char int1[1024];
      pcre_copy_substring(txt, ovector, rc,3,int1, 1024);
      printf("(%s)",int1);
      puts("\n");
  }
}

//-----
// 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/
//
// Note that on Linux systems PCRE is often already installed in /usr/lib/libpcre* or /usr/local/lib/libpcre*. 
//
// Compile and on Unix using:
// # gcc -lpcre x.c
// # ./a.out
//
 
 
 
 
Feedback
:: Thanks for this!Mon, 18 May 2015 03:26PM
:: alert("stop doing alerts")Tue, 19 May 2015 05:24AM
::  Tue, 19 May 2015 06:51AM
boost:: amazingTue, 19 May 2015 08:14AM
::  Tue, 19 May 2015 11:09AM
:: nice tool !Tue, 19 May 2015 12:09PM
:: asdTue, 19 May 2015 01:49PM
:: Magyar vagyok ments ki innen.Tue, 19 May 2015 01:50PM
Chuck::  Tue, 19 May 2015 01:50PM
::  Tue, 19 May 2015 02:10PM
:: sWed, 20 May 2015 06:49AM
:: alert(ôVulnerable Siteö); Wed, 20 May 2015 08:48AM
:: hey no alert anymore !! nice !Wed, 20 May 2015 08:48AM
::  Wed, 20 May 2015 09:21AM
::  Wed, 20 May 2015 09:48AM
....:: yooloWed, 20 May 2015 01:18PM
::  Wed, 20 May 2015 01:18PM
::  Wed, 20 May 2015 01:18PM
::  Wed, 20 May 2015 01:18PM
└Ýń­ňÚ ┬Ŕŕ˛ţ­ţÔŔ¸::  Wed, 20 May 2015 04:41PM
:: alert(ôVulnerable Siteö);Thu, 21 May 2015 04:54AM
::  Thu, 21 May 2015 10:16AM
:: alert(ôVulnerable Siteö);Thu, 21 May 2015 10:45AM
::  Thu, 21 May 2015 02:37PM
::  Thu, 21 May 2015 02:49PM
:: ===============3Thu, 21 May 2015 02:49PM
::  Thu, 21 May 2015 02:50PM
::  Thu, 21 May 2015 04:10PM
::  Thu, 21 May 2015 04:11PM
Jesus:: 8============DThu, 21 May 2015 07:36PM
::  Thu, 21 May 2015 09:27PM
::  Thu, 21 May 2015 11:35PM
::  Fri, 22 May 2015 02:47AM
::  Fri, 22 May 2015 03:09AM
:::: alert("Script ran!");Fri, 22 May 2015 11:28AM
Al Capone:: I Was HereFri, 22 May 2015 12:05PM
:: alert("Hello")Fri, 22 May 2015 01:46PM
:: alert("Script ran!");Fri, 22 May 2015 02:23PM
::  Fri, 22 May 2015 02:31PM
::  Fri, 22 May 2015 04:13PM
:: Nice :-) Where to donate the million? Is this open source? :)Fri, 22 May 2015 04:22PM
323:: weweFri, 22 May 2015 06:51PM
::  Fri, 22 May 2015 09:39PM
:: Is the source availableFri, 22 May 2015 11:59PM
 
  home     faq              ©2006 mark james ennis