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
::  Sat, 13 Sep 2014 08:29PM
dmitry:: that a cool tool thanks :)!Sat, 13 Sep 2014 09:48PM
:: ");alert("fuck you");Sun, 14 Sep 2014 02:35AM
Андрей Викторович::  Sun, 14 Sep 2014 03:30PM
Андрей Викторович::  Sun, 14 Sep 2014 07:31PM
oi:: javascript:alert("fix me");Mon, 15 Sep 2014 10:50AM
::  Tue, 16 Sep 2014 05:35AM
:: you guys are fucking losers, piss off with your inject attempts.Tue, 16 Sep 2014 06:47AM
::  Tue, 16 Sep 2014 08:07AM
:: NOT HELPFUL !!!Tue, 16 Sep 2014 08:07AM
:: It compares character by character and does not give any generic result.. so basically REGEX given by u is specific to that particular string..Tue, 16 Sep 2014 08:08AM
::  Tue, 16 Sep 2014 11:25AM
:: @[User:1638|Sushant Dua]​​ Tue, 16 Sep 2014 11:38AM
Geek AK:: ArgentinaaWed, 17 Sep 2014 04:53AM
ET:: Saved my dayWed, 17 Sep 2014 07:37AM
:: javascript:alert("fix me");Wed, 17 Sep 2014 01:04PM
:: javascript:alert("fix me");Wed, 17 Sep 2014 01:05PM
88::  Wed, 17 Sep 2014 02:12PM
Brazilian Guy:: Don't work for me.Wed, 17 Sep 2014 08:31PM
::  javascript:alert("fix me");Thu, 18 Sep 2014 05:07PM
as:: safFri, 19 Sep 2014 04:24AM
:: javascript:alert("fix me");Fri, 19 Sep 2014 07:22AM
::  Fri, 19 Sep 2014 07:22AM
::  Fri, 19 Sep 2014 07:22AM
::  Fri, 19 Sep 2014 07:22AM
::  Fri, 19 Sep 2014 07:22AM
::  Fri, 19 Sep 2014 07:22AM
::  Fri, 19 Sep 2014 07:22AM
::  Fri, 19 Sep 2014 07:22AM
sasasasa::  Fri, 19 Sep 2014 01:16PM
Paul:: Brilliant! Bookmarked. :o)Fri, 19 Sep 2014 04:23PM
MarkyMark:: Please add Powershell as a languageFri, 19 Sep 2014 09:40PM
mo:: works perfectly for javaSat, 20 Sep 2014 01:07PM
::  Sun, 21 Sep 2014 07:12PM
"#?$%&()/(;"#$%;/)Z>>>x:: "#?$%&()/(;"#$%;/)Z>>>xSun, 21 Sep 2014 07:12PM
::  Mon, 22 Sep 2014 03:18AM
::  Tue, 23 Sep 2014 05:30AM
::  Tue, 23 Sep 2014 08:43AM
23::  Tue, 23 Sep 2014 08:53AM
Lawrence:: Amazing tool. Thanks!Tue, 23 Sep 2014 12:19PM
::  Tue, 23 Sep 2014 03:45PM
' OR 1=1 /*:: " OR 1=1 /*Tue, 23 Sep 2014 03:46PM
::  Tue, 23 Sep 2014 03:51PM
::  Tue, 23 Sep 2014 03:52PM
 
  home     faq              ©2006 mark james ennis