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
 4
d4
2
c 
d2
day2
int42
_
 _
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-cpcre.php3?s=42%2043&2&11&-10&-13

#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[]="(4)";	// Any Single Character 1
  strcat(re,re1);
  char re2[]="(.)";	// Any Single Character 2
  strcat(re,re2);
  char re3[]="( )";	// Any Single Character 3
  strcat(re,re3);
  char re4[]="(\\d+)";	// Integer Number 1
  strcat(re,re4);

  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 c1[1024];
      pcre_copy_substring(txt, ovector, rc,1,c1, 1024);
      printf("(%s)",c1);
      char c2[1024];
      pcre_copy_substring(txt, ovector, rc,2,c2, 1024);
      printf("(%s)",c2);
      char c3[1024];
      pcre_copy_substring(txt, ovector, rc,3,c3, 1024);
      printf("(%s)",c3);
      char int1[1024];
      pcre_copy_substring(txt, ovector, rc,4,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
:: Thats nice sirTue, 7 Oct 2014 07:28AM
Zei:: Amazing stuff, simply pasted in a 2000 character string and it picked out exactly what I wanted.Tue, 7 Oct 2014 02:01PM
Андрей Викторович::  Tue, 7 Oct 2014 09:12PM
HUnter X hunter:: Thanks sir, love thisWed, 8 Oct 2014 11:51AM
Андрей Викторович::  Wed, 8 Oct 2014 03:59PM
:: Thanks a lot. =)Wed, 8 Oct 2014 04:11PM
Robin:: I think this would be quite useful to my work! Thanks.Wed, 8 Oct 2014 09:04PM
:: awesome!Wed, 8 Oct 2014 09:58PM
:: GreatThu, 9 Oct 2014 02:41AM
Fred:: I'm just in love with that toolThu, 9 Oct 2014 10:40AM
::  Thu, 9 Oct 2014 01:19PM
Moin:: I dont care succees joke its coolThu, 9 Oct 2014 10:46PM
Wander:: muito bomFri, 10 Oct 2014 03:16AM
::  Fri, 10 Oct 2014 11:12AM
::  Fri, 10 Oct 2014 11:12AM
::  Fri, 10 Oct 2014 01:40PM
::  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
 
  home     faq              ©2006 mark james ennis