txt 2 re
        headache relief for programmers :: regular expression generator         (perl php python java javascript coldfusion c c++ ruby vb vbscript j# c# c++.net vb.net)
x
 
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
0
c 0
d0
2
c 2
d2
day02
int02
:
c :
M
c M
wM
a
c a
wa
y
c y
wy
varMay
May
monthMay
:
c :
2
c 2
d2
0
c 
d0
1
c 1
d1
2
c 2
d2
day12
year2012
int2012
ddmmmyyyy02:May:2012
_
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 m
wm
p
c p
wp
l
c l
wl
e
c e
we
varExample
wordExample
!
c !
"
c "
"This_is_an_Example!"
< Source String
What to click?  extract any integer in this position
extract this integer (2006) in this position
 
3Perl regular expression program that extracts the selected elements from the entered string:
Zombie Strippers
[Perl] PHP Python Java Javascript ColdFusion C C++ Ruby VB VBScript J#.net C#.net C++.net VB.net 
 
#!/usr/bin/perl
# URL that generated this code:
# http://txt2re.com/index.php3?s=02:May:2012%20%22This%20is%20an%20Example!%22&-67&55&-21&-1&-10
$txt='02:May:2012 "This is an Example!"';
$re1='.*?';	# Non-greedy match on filler
$re2='(May)';	# Word 1
$re3='.*?';	# Non-greedy match on filler
$re4='.';	# Uninteresting: c
$re5='.*?';	# Non-greedy match on filler
$re6='.';	# Uninteresting: c
$re7='.*?';	# Non-greedy match on filler
$re8='(.)';	# Any Single Character 1
$re9='.*?';	# Non-greedy match on filler
$re10='("This is an Example!")';	# Double Quote String 1
$re11='(a)';	# Any Single Character 2
$re=$re1.$re2.$re3.$re4.$re5.$re6.$re7.$re8.$re9.$re10.$re11;
if ($txt =~ m/$re/is)
{
    $word1=$1;
    $c1=$2;
    $string1=$3;
    $c2=$4;
    print "($word1) ($c1) ($string1) ($c2) \n";
}
#-----
# Paste the code into a new perl file. Then in Unix:
# $ perl x.pl 
#-----
 
 
 
 
Feedback
jtfkpr:: CsYptOlBfgoFYfiJQgTue, 20 Nov 2012 11:30PM
todds:: Many thanks! Ever considered making this open source?Tue, 20 Nov 2012 11:38PM
123:: 123Wed, 21 Nov 2012 07:10AM
::  22*9696195963*100Wed, 21 Nov 2012 08:35AM
123::  Wed, 21 Nov 2012 08:44AM
::  Wed, 21 Nov 2012 08:58PM
::  Fri, 23 Nov 2012 06:44AM
:: kooSun, 25 Nov 2012 05:15AM
::  Sun, 25 Nov 2012 05:15AM
::  Mon, 26 Nov 2012 09:22PM
:: How the hell am I supposed to know what to pick?Tue, 27 Nov 2012 12:31AM
mat - c#:: you select the items you want to regex in ur program ....Tue, 27 Nov 2012 06:55AM
::  Tue, 27 Nov 2012 01:46PM
Vin.k.S:: Awesome :) code :)Tue, 27 Nov 2012 01:47PM
Miguel:: Finnaly some one got it right !!! the best RegEx tool ever!Wed, 28 Nov 2012 01:24AM
::  Wed, 28 Nov 2012 03:40AM
2423:: coolWed, 28 Nov 2012 03:41AM
::  Wed, 28 Nov 2012 05:29AM
:: l;lWed, 28 Nov 2012 05:29AM
::  Wed, 28 Nov 2012 07:06AM
::  Wed, 28 Nov 2012 08:22AM
Juggler:: No multiline strings unfortunately!Wed, 28 Nov 2012 08:22AM
nutz:: Kool Tool. ThanksWed, 28 Nov 2012 02:54PM
nutz:: Kool Tool. ThanksWed, 28 Nov 2012 02:54PM
::  Wed, 28 Nov 2012 03:38PM
nice:: niceWed, 28 Nov 2012 04:31PM
as:: alert("");Thu, 29 Nov 2012 05:31AM
::  Thu, 29 Nov 2012 05:52AM
john:: mantabb... tools sakti nihThu, 29 Nov 2012 06:24AM
john:: mantabb... tools sakti nihThu, 29 Nov 2012 06:24AM
::  Thu, 29 Nov 2012 06:37AM
:: FUCKING ROCKSThu, 29 Nov 2012 02:29PM
Luis:: The Best!!!!!!!Thu, 29 Nov 2012 04:08PM
Rainbowwwww:: ima gawd! thx :DThu, 29 Nov 2012 05:26PM
::  Thu, 29 Nov 2012 09:58PM
:: Please add a regex only option. This will give us 1 line that contains all the regex. :-) thx!Fri, 30 Nov 2012 03:52PM
Peter:: This is amazing. Thank you so much! Like todds said you should consider open sourcing this.Mon, 3 Dec 2012 03:24AM
::  Mon, 3 Dec 2012 03:43AM
(Ivideon\ Q\&A;)::  Mon, 3 Dec 2012 02:59PM
::  Mon, 3 Dec 2012 03:25PM
Nishant:: Superb :)Tue, 4 Dec 2012 06:20AM
thefab:: AwesomeTue, 4 Dec 2012 06:43PM
newbie:: I subscribe adding a regex only option. This will give us 1 line that contains all the regex. :-) thx!Wed, 5 Dec 2012 01:28AM
Sexy Boy 69:: BITCHASS AWESOMEWed, 5 Dec 2012 08:37AM
 
  home     faq