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
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
12
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:
[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&-1&-10&-14
$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='(12)';	# Day 1
$re5='.*?';	# Non-greedy match on filler
$re6='("This is an Example!")';	# Double Quote String 1
$re=$re1.$re2.$re3.$re4.$re5.$re6;
if ($txt =~ m/$re/is)
{
    $word1=$1;
    $day1=$2;
    $string1=$3;
    print "($word1) ($day1) ($string1) \n";
}
#-----
# Paste the code into a new perl file. Then in Unix:
# $ perl x.pl 
#-----
 
 
 
 
Feedback
grrg:: rgrgrg rg r gr Fri, 29 Jun 2012 12:32PM
matiszon:: Very thank u for this!Fri, 29 Jun 2012 12:36PM
JMR:: Thanks!!!! It's a very powerfull tool!Fri, 29 Jun 2012 06:36PM
:: ........Fri, 29 Jun 2012 06:40PM
Brian:: very niceFri, 29 Jun 2012 08:09PM
���:: ���Sun, 1 Jul 2012 12:59PM
::  Mon, 2 Jul 2012 07:45AM
::  Mon, 2 Jul 2012 07:59AM
:: good job!Mon, 2 Jul 2012 10:21AM
a female faust:: searched for THIS tool because it is the BESTMon, 2 Jul 2012 11:28AM
:: thax..! Mon, 2 Jul 2012 12:06PM
::  Mon, 2 Jul 2012 07:52PM
justin beiber:: amazing stuff!Mon, 2 Jul 2012 08:18PM
:: nice toolTue, 3 Jul 2012 11:57AM
Graph:: Nice!Tue, 3 Jul 2012 03:41PM
Jan:: this is amazing tool! Will you open source it?Tue, 3 Jul 2012 07:39PM
Danny:: I would LOVE to see PowerShell as an output option Tue, 3 Jul 2012 10:23PM
:: +1 for Jan. Looks like wonderful code.Wed, 4 Jul 2012 11:50AM
-1':: 1Wed, 4 Jul 2012 08:20PM
1:: -1'Wed, 4 Jul 2012 08:20PM
1:: 1Wed, 4 Jul 2012 08:20PM
::  Thu, 5 Jul 2012 10:37AM
:: love dat tool Thu, 5 Jul 2012 06:29PM
jm:: Thanks for a great toolThu, 5 Jul 2012 07:28PM
ok:: goodThu, 5 Jul 2012 07:55PM
Boy Person:: I'm a girlThu, 5 Jul 2012 08:31PM
JZ:: Awesome! Thu, 5 Jul 2012 10:26PM
:: veryyyyy niceFri, 6 Jul 2012 10:19AM
:: will defnitely use this to learn regex, bookmarkedFri, 6 Jul 2012 10:20AM
christarp:: WHAT DOES THIS DOFri, 6 Jul 2012 01:38PM
::  Fri, 6 Jul 2012 02:02PM
jim:: 44:22:36 couldn't match 44 hoursFri, 6 Jul 2012 03:42PM
caublet:: could you add bash plzFri, 6 Jul 2012 04:19PM
ppyxn:: thank you very much for this, it is really a headache relief :DSat, 7 Jul 2012 04:40AM
-1':: 1Sat, 7 Jul 2012 08:04AM
1:: -1'Sat, 7 Jul 2012 08:04AM
1:: 1Sat, 7 Jul 2012 08:04AM
::  Sun, 8 Jul 2012 12:00AM
sev:: great tool, i tip my hat to youSun, 8 Jul 2012 12:19AM
fromRUSSIAwithLove:: Perfect tool! It's very powerful and very helpful! Thanx bros!!!Sun, 8 Jul 2012 10:18AM
akash:: How to detect new line Sun, 8 Jul 2012 10:25AM
::  Sun, 8 Jul 2012 10:30AM
fromRUSSIAwithLove:: Perfect tool! It's very powerful and very helpful! Thanx bros!!!Sun, 8 Jul 2012 10:44AM
::  Mon, 9 Jul 2012 04:04AM
 
  home     faq