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)
 
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
5
c 5
d5
day05
int05
:
c :
O
c O
wO
c
c c
wc
t
c t
wt
usstatect
varOct
Oct
monthOct
:
c :
2
c 2
d2
0
c 0
d0
1
c 1
d1
1
c 1
d1
day11
year2011
int2011
ddmmmyyyy05:Oct:2011
_
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:
[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=05:Oct:2011%20%22This%20is%20an%20Example!%22&-11&-10&-1
$txt='05:Oct:2011 "This is an Example!"';
$re1='.*?';	# Non-greedy match on filler
$re2='(Oct)';	# Word 1
$re3='.*?';	# Non-greedy match on filler
$re4='("This is an Example!")';	# Double Quote String 1
$re=$re1.$re2.$re3.$re4;
if ($txt =~ m/$re/is)
{
    $word1=$1;
    $string1=$2;
    print "($word1) ($string1) \n";
}
#-----
# Paste the code into a new perl file. Then in Unix:
# $ perl x.pl 
#-----
plain text version of code
 
 
 
 
Feedback
:: cool =)Mon, 28 Nov 2011 05:36PM
Sean:: That is awesome! I have been planning, but too lazy to put something like this together, because it will be hideously useful to me. THANKS!Tue, 29 Nov 2011 12:59AM
Justin:: Thank you so much. This has made my regex work so much easier no.Tue, 29 Nov 2011 05:04PM
::  Wed, 30 Nov 2011 12:07AM
rolax:: Esto es genialWed, 30 Nov 2011 01:39AM
:: Could you add checks for hexadecimal values? I would also like one for hostname OR ip addressWed, 30 Nov 2011 11:12AM
nottu2584:: thanks a lot, works wonders!!Wed, 30 Nov 2011 12:06PM
::  Wed, 30 Nov 2011 02:40PM
demo:: holaWed, 30 Nov 2011 03:25PM
FjMe:: esta chevereWed, 30 Nov 2011 03:30PM
::  Wed, 30 Nov 2011 04:06PM
jorge:: muchas gracias me sirvi� bastante.Wed, 30 Nov 2011 09:19PM
:: Heck yeah!Wed, 30 Nov 2011 10:18PM
::  Wed, 30 Nov 2011 10:49PM
Cristian:: buena la idea y a la vez muy utilWed, 30 Nov 2011 10:50PM
����:: �죬�dz�coolThu, 1 Dec 2011 08:03AM
::  Thu, 1 Dec 2011 09:05AM
:: lol wut?Thu, 1 Dec 2011 05:02PM
urielx:: I always wanted to programm something like this for people who dont' understand RE!Thu, 1 Dec 2011 06:25PM
:: love it !Fri, 2 Dec 2011 07:16PM
::  Fri, 2 Dec 2011 11:34PM
TROLOLO:: TROLOLO GEEGEE BROFri, 2 Dec 2011 11:34PM
beej:: possibly the coolest regex system online, thank you so much for providing me with this service!!Sat, 3 Dec 2011 08:46AM
Jen:: your logo made me laugh, your app is a life-saver, you're awesome, thanks!Sun, 4 Dec 2011 12:26PM
Katherine:: Really really helpful. thanks so much!Sun, 4 Dec 2011 11:02PM
hpkvppj:: vNZrfnQEbgxICLMon, 5 Dec 2011 02:08AM
::  Mon, 5 Dec 2011 11:54AM
:: Sab�r Sava� ZaferMon, 5 Dec 2011 11:54AM
:: a AWK output would be nice - I usually use AWK for regexp and they usually ne 60 minutes of debuggingMon, 5 Dec 2011 04:01PM
:: Brilliant!Tue, 6 Dec 2011 08:58AM
rohan:: super helpful !!Tue, 6 Dec 2011 02:38PM
::  Wed, 7 Dec 2011 08:11AM
Joker:: MLGB!Wed, 7 Dec 2011 08:12AM
Roshan:: WTF?Wed, 7 Dec 2011 08:15AM
Roshan:: WTF?Wed, 7 Dec 2011 08:17AM
Roshan:: WTF?Wed, 7 Dec 2011 08:17AM
poppo:: Stupenda!!!!Wed, 7 Dec 2011 04:04PM
:: LOLWed, 7 Dec 2011 05:45PM
::  Thu, 8 Dec 2011 12:57AM
::  Thu, 8 Dec 2011 01:58PM
Jo:: Thanks Greate workThu, 8 Dec 2011 01:58PM
::  Thu, 8 Dec 2011 07:25PM
:: um, how do I just see the regex without the code?!Fri, 9 Dec 2011 01:48PM
vivek:: awesome !Sat, 10 Dec 2011 12:34AM
 
  home     faq