Skip to content

Instantly share code, notes, and snippets.

@tonussi
Created April 19, 2013 14:10
Show Gist options
  • Save tonussi/5420593 to your computer and use it in GitHub Desktop.
Save tonussi/5420593 to your computer and use it in GitHub Desktop.
text2re
<!-- URL that generated this code: -->
<!-- http://txt2re.com/index-javascript.php3?s=55998-episode-0-8-4-news-roundup.mp3&6&-55&-2&-56&46&-57&52&-58&48&-59&7&1 -->
<html>
<body>
<script language=javascript>
var txt='55998-episode-0-8-4-news-roundup.mp3';
var re1='(\\d+)'; // Integer Number 1
var re2='(-)'; // Any Single Character 1
var re3='(episode)'; // Word 1
var re4='(-)'; // Any Single Character 2
var re5='(\\d)'; // Any Single Digit 1
var re6='(-)'; // Any Single Character 3
var re7='(\\d)'; // Any Single Digit 2
var re8='(-)'; // Any Single Character 4
var re9='(\\d)'; // Any Single Digit 3
var re10='(-)'; // Any Single Character 5
var re11='((?:[a-z][a-z]+))'; // Word 2
var re12='.*?'; // Non-greedy match on filler
var re13='((?:[a-z][a-z\\.\\d_]+)\\.(?:[a-z\\d]{3}))(?![\\w\\.])'; // File Name 1
var p = new RegExp(re1+re2+re3+re4+re5+re6+re7+re8+re9+re10+re11+re12+re13,["i"]);
var m = p.exec(txt);
if (m != null)
{
var int1=m[1];
var c1=m[2];
var word1=m[3];
var c2=m[4];
var d1=m[5];
var c3=m[6];
var d2=m[7];
var c4=m[8];
var d3=m[9];
var c5=m[10];
var word2=m[11];
var file1=m[12];
document.write("("+int1.replace(/</,"&lt;")+")"+"("+c1.replace(/</,"&lt;")+")"+"("+word1.replace(/</,"&lt;")+")"+"("+c2.replace(/</,"&lt;")+")"+"("+d1.replace(/</,"&lt;")+")"+"("+c3.replace(/</,"&lt;")+")"+"("+d2.replace(/</,"&lt;")+")"+"("+c4.replace(/</,"&lt;")+")"+"("+d3.replace(/</,"&lt;")+")"+"("+c5.replace(/</,"&lt;")+")"+"("+word2.replace(/</,"&lt;")+")"+"("+file1.replace(/</,"&lt;")+")"+"\n");
}
</script>
</body>
</html>
<!-- -->
<!-- Paste the code into a file that can be served by your web server -->
<!-- or into a local file that can be read by your browser -->
<!-- -->
// URL that generated this code:
// http://txt2re.com/index-java.php3?s=55998-episode-0-8-4-news-roundup.mp3&6&-55&-2&-56&46&-57&52&-58&48&-59&7&1
import java.util.regex.*;
class Main
{
public static void main(String[] args)
{
String txt="55998-episode-0-8-4-news-roundup.mp3";
String re1="(\\d+)"; // Integer Number 1
String re2="(-)"; // Any Single Character 1
String re3="(episode)"; // Word 1
String re4="(-)"; // Any Single Character 2
String re5="(\\d)"; // Any Single Digit 1
String re6="(-)"; // Any Single Character 3
String re7="(\\d)"; // Any Single Digit 2
String re8="(-)"; // Any Single Character 4
String re9="(\\d)"; // Any Single Digit 3
String re10="(-)"; // Any Single Character 5
String re11="((?:[a-z][a-z]+))"; // Word 2
String re12=".*?"; // Non-greedy match on filler
String re13="((?:[a-z][a-z\\.\\d_]+)\\.(?:[a-z\\d]{3}))(?![\\w\\.])"; // File Name 1
Pattern p = Pattern.compile(re1+re2+re3+re4+re5+re6+re7+re8+re9+re10+re11+re12+re13,Pattern.CASE_INSENSITIVE | Pattern.DOTALL);
Matcher m = p.matcher(txt);
if (m.find())
{
String int1=m.group(1);
String c1=m.group(2);
String word1=m.group(3);
String c2=m.group(4);
String d1=m.group(5);
String c3=m.group(6);
String d2=m.group(7);
String c4=m.group(8);
String d3=m.group(9);
String c5=m.group(10);
String word2=m.group(11);
String file1=m.group(12);
System.out.print("("+int1.toString()+")"+"("+c1.toString()+")"+"("+word1.toString()+")"+"("+c2.toString()+")"+"("+d1.toString()+")"+"("+c3.toString()+")"+"("+d2.toString()+")"+"("+c4.toString()+")"+"("+d3.toString()+")"+"("+c5.toString()+")"+"("+word2.toString()+")"+"("+file1.toString()+")"+"\n");
}
}
}
//-----
// This code is for use with Sun's Java VM - see http://java.sun.com/ for downloads.
//
// Paste the code into a new java application or a file called 'Main.java'
//
// Compile and run in Unix using:
// # javac Main.java
// # java Main
//
// URL that generated this code:
// http://txt2re.com/index-c++.php3?s=55998-episode-0-8-4-news-roundup.mp3&6&-55&-2&-56&46&-57&52&-58&48&-59&7&1
#include <stdlib.h>
#include <string>
#include <iostream>
#include <pme.h>
int main()
{
std::string txt="55998-episode-0-8-4-news-roundup.mp3";
std::string re1="(\\d+)"; // Integer Number 1
std::string re2="(-)"; // Any Single Character 1
std::string re3="(episode)"; // Word 1
std::string re4="(-)"; // Any Single Character 2
std::string re5="(\\d)"; // Any Single Digit 1
std::string re6="(-)"; // Any Single Character 3
std::string re7="(\\d)"; // Any Single Digit 2
std::string re8="(-)"; // Any Single Character 4
std::string re9="(\\d)"; // Any Single Digit 3
std::string re10="(-)"; // Any Single Character 5
std::string re11="((?:[a-z][a-z]+))"; // Word 2
std::string re12=".*?"; // Non-greedy match on filler
std::string re13="((?:[a-z][a-z\\.\\d_]+)\\.(?:[a-z\\d]{3}))(?![\\w\\.])"; // File Name 1
PME re(re1+re2+re3+re4+re5+re6+re7+re8+re9+re10+re11+re12+re13,"gims");
int n;
if ((n=re.match(txt))>0)
{
std::string int1=re[1].c_str();
std::string c1=re[2].c_str();
std::string word1=re[3].c_str();
std::string c2=re[4].c_str();
std::string d1=re[5].c_str();
std::string c3=re[6].c_str();
std::string d2=re[7].c_str();
std::string c4=re[8].c_str();
std::string d3=re[9].c_str();
std::string c5=re[10].c_str();
std::string word2=re[11].c_str();
std::string file1=re[12].c_str();
std::cout << "("<<int1<<")"<<"("<<c1<<")"<<"("<<word1<<")"<<"("<<c2<<")"<<"("<<d1<<")"<<"("<<c3<<")"<<"("<<d2<<")"<<"("<<c4<<")"<<"("<<d3<<")"<<"("<<c5<<")"<<"("<<word2<<")"<<"("<<file1<<")"<< std::endl;
}
}
//-----
// 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/ and
// the PME library from ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/Contrib/
//
// Note that on Linux systems PCRE is often already installed in /usr/lib/libpcre* or /usr/local/lib/libpcre*.
//
// Compile and run on Unix using
// # c++ x.cpp -lpme -lpcre
// # ./a.out
//
<?php
# URL that generated this code:
# http://txt2re.com/index-php.php3?s=55998-episode-0-8-4-news-roundup.mp3&6&-55&-2&-56&46&-57&52&-58&48&-59&7&1
$txt='55998-episode-0-8-4-news-roundup.mp3';
$re1='(\\d+)'; # Integer Number 1
$re2='(-)'; # Any Single Character 1
$re3='(episode)'; # Word 1
$re4='(-)'; # Any Single Character 2
$re5='(\\d)'; # Any Single Digit 1
$re6='(-)'; # Any Single Character 3
$re7='(\\d)'; # Any Single Digit 2
$re8='(-)'; # Any Single Character 4
$re9='(\\d)'; # Any Single Digit 3
$re10='(-)'; # Any Single Character 5
$re11='((?:[a-z][a-z]+))'; # Word 2
$re12='.*?'; # Non-greedy match on filler
$re13='((?:[a-z][a-z\\.\\d_]+)\\.(?:[a-z\\d]{3}))(?![\\w\\.])'; # File Name 1
if ($c=preg_match_all ("/".$re1.$re2.$re3.$re4.$re5.$re6.$re7.$re8.$re9.$re10.$re11.$re12.$re13."/is", $txt, $matches))
{
$int1=$matches[1][0];
$c1=$matches[2][0];
$word1=$matches[3][0];
$c2=$matches[4][0];
$d1=$matches[5][0];
$c3=$matches[6][0];
$d2=$matches[7][0];
$c4=$matches[8][0];
$d3=$matches[9][0];
$c5=$matches[10][0];
$word2=$matches[11][0];
$file1=$matches[12][0];
print "($int1) ($c1) ($word1) ($c2) ($d1) ($c3) ($d2) ($c4) ($d3) ($c5) ($word2) ($file1) \n";
}
#-----
# Paste the code into a new php file. Then in Unix:
# $ php x.php
#-----
?>
#!/usr/bin/perl
# URL that generated this code:
# http://txt2re.com/index-perl.php3?s=55998-episode-0-8-4-news-roundup.mp3&6&-55&-2&-56&46&-57&52&-58&48&-59&7&1
$txt='55998-episode-0-8-4-news-roundup.mp3';
$re1='(\\d+)'; # Integer Number 1
$re2='(-)'; # Any Single Character 1
$re3='(episode)'; # Word 1
$re4='(-)'; # Any Single Character 2
$re5='(\\d)'; # Any Single Digit 1
$re6='(-)'; # Any Single Character 3
$re7='(\\d)'; # Any Single Digit 2
$re8='(-)'; # Any Single Character 4
$re9='(\\d)'; # Any Single Digit 3
$re10='(-)'; # Any Single Character 5
$re11='((?:[a-z][a-z]+))'; # Word 2
$re12='.*?'; # Non-greedy match on filler
$re13='((?:[a-z][a-z\\.\\d_]+)\\.(?:[a-z\\d]{3}))(?![\\w\\.])'; # File Name 1
$re=$re1.$re2.$re3.$re4.$re5.$re6.$re7.$re8.$re9.$re10.$re11.$re12.$re13;
if ($txt =~ m/$re/is)
{
$int1=$1;
$c1=$2;
$word1=$3;
$c2=$4;
$d1=$5;
$c3=$6;
$d2=$7;
$c4=$8;
$d3=$9;
$c5=$10;
$word2=$11;
$file1=$12;
print "($int1) ($c1) ($word1) ($c2) ($d1) ($c3) ($d2) ($c4) ($d3) ($c5) ($word2) ($file1) \n";
}
#-----
# Paste the code into a new perl file. Then in Unix:
# $ perl x.pl
#-----
#!/usr/bin/python
# URL that generated this code:
# http://txt2re.com/index-python.php3?s=55998-episode-0-8-4-news-roundup.mp3&6&-55&-2&-56&46&-57&52&-58&48&-59&7&1
import re
txt='55998-episode-0-8-4-news-roundup.mp3'
re1='(\\d+)' # Integer Number 1
re2='(-)' # Any Single Character 1
re3='(episode)' # Word 1
re4='(-)' # Any Single Character 2
re5='(\\d)' # Any Single Digit 1
re6='(-)' # Any Single Character 3
re7='(\\d)' # Any Single Digit 2
re8='(-)' # Any Single Character 4
re9='(\\d)' # Any Single Digit 3
re10='(-)' # Any Single Character 5
re11='((?:[a-z][a-z]+))' # Word 2
re12='.*?' # Non-greedy match on filler
re13='((?:[a-z][a-z\\.\\d_]+)\\.(?:[a-z\\d]{3}))(?![\\w\\.])' # File Name 1
rg = re.compile(re1+re2+re3+re4+re5+re6+re7+re8+re9+re10+re11+re12+re13,re.IGNORECASE|re.DOTALL)
m = rg.search(txt)
if m:
int1=m.group(1)
c1=m.group(2)
word1=m.group(3)
c2=m.group(4)
d1=m.group(5)
c3=m.group(6)
d2=m.group(7)
c4=m.group(8)
d3=m.group(9)
c5=m.group(10)
word2=m.group(11)
file1=m.group(12)
print "("+int1+")"+"("+c1+")"+"("+word1+")"+"("+c2+")"+"("+d1+")"+"("+c3+")"+"("+d2+")"+"("+c4+")"+"("+d3+")"+"("+c5+")"+"("+word2+")"+"("+file1+")"+"\n"
#-----
# Paste the code into a new python file. Then in Unix:'
# $ python x.py
#-----
# URL that generated this code:
# http://txt2re.com/index-ruby.php3?s=55998-episode-0-8-4-news-roundup.mp3&6&-55&-2&-56&46&-57&52&-58&48&-59&7&1
#!/usr/bin/ruby
txt='55998-episode-0-8-4-news-roundup.mp3'
re1='(\\d+)' # Integer Number 1
re2='(-)' # Any Single Character 1
re3='(episode)' # Word 1
re4='(-)' # Any Single Character 2
re5='(\\d)' # Any Single Digit 1
re6='(-)' # Any Single Character 3
re7='(\\d)' # Any Single Digit 2
re8='(-)' # Any Single Character 4
re9='(\\d)' # Any Single Digit 3
re10='(-)' # Any Single Character 5
re11='((?:[a-z][a-z]+))' # Word 2
re12='.*?' # Non-greedy match on filler
re13='((?:[a-z][a-z\\.\\d_]+)\\.(?:[a-z\\d]{3}))(?![\\w\\.])' # File Name 1
re=(re1+re2+re3+re4+re5+re6+re7+re8+re9+re10+re11+re12+re13)
m=Regexp.new(re,Regexp::IGNORECASE);
if m.match(txt)
int1=m.match(txt)[1];
c1=m.match(txt)[2];
word1=m.match(txt)[3];
c2=m.match(txt)[4];
d1=m.match(txt)[5];
c3=m.match(txt)[6];
d2=m.match(txt)[7];
c4=m.match(txt)[8];
d3=m.match(txt)[9];
c5=m.match(txt)[10];
word2=m.match(txt)[11];
file1=m.match(txt)[12];
puts "("<<int1<<")"<<"("<<c1<<")"<<"("<<word1<<")"<<"("<<c2<<")"<<"("<<d1<<")"<<"("<<c3<<")"<<"("<<d2<<")"<<"("<<c4<<")"<<"("<<d3<<")"<<"("<<c5<<")"<<"("<<word2<<")"<<"("<<file1<<")"<< "\n"
end
#-----
# Paste the code into a new ruby file.
# $ ruby x.ruby
#-----
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment