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 0
d0
1
c 1
d1
2
c 2
d2
day12
year
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&-33&6&-24&-10&-1
$txt='02:May:2012 "This is an Example!"';
$re1='.*?';	# Non-greedy match on filler
$re2='(May)';	# Word 1
$re3='(M)';	# Any Single Word Character (Not Whitespace) 1
$re4='.*?';	# Non-greedy match on filler
$re5='((?:(?:[1]{1}\\d{1}\\d{1}\\d{1})|(?:[2]{1}\\d{3})))(?![\\d])';	# Year 1
$re6='.*?';	# Non-greedy match on filler
$re7='("This is an Example!")';	# Double Quote String 1
$re8='(l)';	# Any Single Word Character (Not Whitespace) 2
$re=$re1.$re2.$re3.$re4.$re5.$re6.$re7.$re8;
if ($txt =~ m/$re/is)
{
    $word1=$1;
    $w1=$2;
    $year1=$3;
    $string1=$4;
    $w2=$5;
    print "($word1) ($w1) ($year1) ($string1) ($w2) \n";
}
#-----
# Paste the code into a new perl file. Then in Unix:
# $ perl x.pl 
#-----
 
 
 
 
Feedback
:: 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
:: 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
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
Newbie User:: Great tool, thanks!!Wed, 5 Dec 2012 04:40PM
John:: You Sir are a Saint!!!!Thu, 6 Dec 2012 07:26AM
cookiefrutti:: thanks for the hard work! just to know, you have regex for days, years, but the one for months is missingFri, 7 Dec 2012 02:59PM
YouRock:: I want to have your kids man!!!!!Fri, 7 Dec 2012 04:31PM
Torsten:: In extremly helpful tool to explain regular expression to newbiesSat, 8 Dec 2012 08:17AM
shake10861:: This is awesome, so very very useful! Thank you so much!Tue, 11 Dec 2012 05:40PM
Patrick Kanne:: YES!! thankyouthankyouthankyou!!! oh, and, thank you!!Wed, 12 Dec 2012 01:17PM
GrandParent:: Saves my day. Thank you so much!!Thu, 13 Dec 2012 12:44PM
WHK:: thanks :)Thu, 13 Dec 2012 09:11PM
Intrepid:: Genius!! Brilliant implementation!Fri, 14 Dec 2012 12:10AM
batkam:: wowwwwwwwwwwwwwwwwwFri, 14 Dec 2012 10:21AM
test:: hhFri, 14 Dec 2012 02:09PM
wrato:: man.. this is awesome!!!!!!Fri, 14 Dec 2012 02:13PM
asdf:: fdgdfgMon, 17 Dec 2012 04:36AM
::  Mon, 17 Dec 2012 10:44AM
::  Mon, 17 Dec 2012 10:51AM
ARk:: i love this! you are monster!Mon, 17 Dec 2012 12:03PM
Roger:: Fucking Ass!!!Mon, 17 Dec 2012 01:14PM
:: Freaking awesome!!!Tue, 18 Dec 2012 05:24AM
::  Tue, 18 Dec 2012 06:26AM
::  Tue, 18 Dec 2012 12:32PM
cic1988:: Good job! :-DTue, 18 Dec 2012 12:36PM
ravi.jsr:: Cool stuffTue, 18 Dec 2012 01:44PM
:: This interface is more confusing than regex itself.Tue, 18 Dec 2012 02:08PM
jdell:: Awesome!Wed, 19 Dec 2012 11:07AM
Centewhy:: Excellent, very nice!Wed, 19 Dec 2012 02:35PM
AdrianH:: Interesting implementation. Good job.Wed, 19 Dec 2012 04:55PM
JohnH:: any chance you're willing to share the code? Would like to use this to make mod_security rules.Wed, 19 Dec 2012 09:25PM
Steve:: man... whoever you are... this is the best.. and I mean.. THE BEST implementation of regex! THANK YOU!Thu, 20 Dec 2012 03:16AM
::  Thu, 20 Dec 2012 09:28AM
:: i love itThu, 20 Dec 2012 05:52PM
Aswathy:: How can exclude string?Fri, 21 Dec 2012 08:53AM
Luis:: Rocks again!Fri, 21 Dec 2012 08:22PM
Afif:: Many thanks!Fri, 21 Dec 2012 08:32PM
::  Fri, 21 Dec 2012 08:32PM
 
  home     faq