txt 2 re
knowing is obsolete :: 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
4
 4
d4
2
c 2
d2
day2
int42
_
c 
ws_
4
c 4
d4
3
c 3
d3
day3
int
< Source String
What to click?  extract any integer in this position
extract this integer (2006) in this position
 
3Java 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 
 
// URL that generated this code:
// http://txt2re.com/index-java.php3?s=42%2043&2&-13&10 

import java.util.regex.*;

class Main
{
  public static void main(String[] args)
  {
    String txt="42 43";

    String re1="(4)";	// Any Single Character 1
    String re2=".*?";	// Non-greedy match on filler
    String re3=".";	// Uninteresting: c
    String re4=".*?";	// Non-greedy match on filler
    String re5="(.)";	// Any Single Character 2
    String re6="(\\d+)";	// Integer Number 1

    Pattern p = Pattern.compile(re1+re2+re3+re4+re5+re6,Pattern.CASE_INSENSITIVE | Pattern.DOTALL);
    Matcher m = p.matcher(txt);
    if (m.find())
    {
        String c1=m.group(1);
        String c2=m.group(2);
        String int1=m.group(3);
        System.out.print("("+c1.toString()+")"+"("+c2.toString()+")"+"("+int1.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 
//
 
 
 
 
Feedback
::  alert('hahahah');Sun, 21 Jun 2015 12:50PM
as:: lasSun, 21 Jun 2015 06:05PM
:: saved my assMon, 22 Jun 2015 07:12PM
:: eeeeeehhhhhhhhhhhhhhhhhh?????????????Mon, 22 Jun 2015 07:13PM
:: hiMon, 22 Jun 2015 08:54PM
::  Mon, 22 Jun 2015 11:03PM
.|.:: me lleva la vergaMon, 22 Jun 2015 11:03PM
.|.:: me lleva la vergaMon, 22 Jun 2015 11:03PM
:o):: thanksTue, 23 Jun 2015 03:36PM
11:: 11Tue, 23 Jun 2015 05:11PM
cheez-it:: yesTue, 23 Jun 2015 07:14PM
::  Tue, 23 Jun 2015 09:27PM
blandcramration:: fuck yeah, bitchin' dudeTue, 23 Jun 2015 09:27PM
::  Tue, 23 Jun 2015 10:49PM
::  Tue, 23 Jun 2015 10:49PM
::  Tue, 23 Jun 2015 10:49PM
::  Tue, 23 Jun 2015 10:49PM
::  Tue, 23 Jun 2015 10:49PM
zeeeepy:: this is awesommmmmmmmmmmmmTue, 23 Jun 2015 10:50PM
fabqjailcg:: LDiabyzjANWed, 24 Jun 2015 03:25AM
opxgajhd:: suJUBPrLdOFWMFqrWed, 24 Jun 2015 04:08AM
Radu:: many thanks for the AWESOME toolWed, 24 Jun 2015 06:18AM
thisguy:: this is a fantastic tool and I speak on behalf of mankind when I thank you for it.Wed, 24 Jun 2015 07:50AM
comentario::  Wed, 24 Jun 2015 03:43PM
::  Wed, 24 Jun 2015 11:42PM
::  Thu, 25 Jun 2015 10:35AM
::  Thu, 25 Jun 2015 02:12PM
goganavt:: coolThu, 25 Jun 2015 02:12PM
:-/:: cool but how to use itThu, 25 Jun 2015 06:25PM
:: amazing. thanksThu, 25 Jun 2015 11:54PM
:D:: great, but a little unintuitiveFri, 26 Jun 2015 02:00AM
test:: alert('haha');Fri, 26 Jun 2015 07:49AM
1|2|3|4|5:: 12345Fri, 26 Jun 2015 08:39AM
Anonymous:: Amazing!! Saved me 2 hours of learning and coding.Fri, 26 Jun 2015 05:21PM
d::  Sat, 27 Jun 2015 03:51AM
:: \Sat, 27 Jun 2015 03:51AM
:: <Sat, 27 Jun 2015 03:52AM
:: <script>alert("yeah")<\script>Sat, 27 Jun 2015 03:53AM
::  Mon, 29 Jun 2015 09:09AM
::  Mon, 29 Jun 2015 10:40PM
:: alert("yeah")Mon, 29 Jun 2015 11:50PM
:: alert("yeah")Mon, 29 Jun 2015 11:50PM
:: function(){alert("yeah")}();Mon, 29 Jun 2015 11:51PM
:: function(){alert("yeah")}();Mon, 29 Jun 2015 11:51PM
 
  home     faq              ©2006 mark james ennis