Hello, I've got a regular expression code on Perl but I have to rewrite it in Java. My Perl code is:
use strict; undef $/; $_ = <DATA>; while(m% ^-------- \s+ (\S+) \s+ (\S+) \s+ LINE\s*=\s*(\d+) \s+ STN\s*=\s*(\d+) \s+ CALLING\ NUMBER \s+ (\d+) \s+ (?:^(?:[ \t]+.*)?[\n\r]+)* # eat unwanted part ^(\d\d:\d\d:\d\d) \s+ INCOMING\ CALL \s+ RINGING\ ([\d:]+) \s* (?:^\d.*[\r\n]+)* # possible stuff ^(\d\d:\d\d:\d\d) \s+ CALL\ RELEASED %gxm){ print "* Match: $1, $2, $3, $4, $5, $6, $7, $8\n"; } __DATA__ -------- 05/25/11 04:05:00 RECORD RESTART *052511 074217 0065 02242806000 UNKNOWN U G *052511 074217 0065 4874 02242806000 UNKNOWN U A *052511 074218 0065 4874 02242806000 UNKNOWN U R -------- 05/25/11 07:42:17 LINE = 0065 STN = 4874 CALLING NUMBER 02242806000 NAME UNKNOWN UNKNOWN BC = SPEECH 00:00:00 INCOMING CALL RINGING 0:02 00:00:01 CALL RELEASED -------- 05/25/11 07:42:19 LINE = 0010 LINE = 0065 BC = EXT CALL FORWARD LINE = 0918 REASO +N = VOIP CALL 00:00:00 OUTGOING CALL DIGITS DIALED 5663 00:00:19 CALL RELEASED *052511 075639 0067 4595595 UNKNOWN U G *052511 075639 0067 4874 4595595 UNKNOWN U A *052511 075641 0067 4874 4595595 UNKNOWN U R -------- 05/25/11 07:56:39 LINE = 0067 STN = 4874 CALLING NUMBER 4595595 NAME UNKNOWN UNKNOWN BC = SPEECH 00:00:00 INCOMING CALL RINGING 0:02 00:00:02 CALL RELEASED *052511 075701 0073 4583677 UNKNOWN U G *052511 075701 0073 4874 4583677 UNKNOWN U A *052511 075703 0073 4874 4583677 UNKNOWN U R -------- 05/25/11 07:57:01 LINE = 0073 STN = 4874 CALLING NUMBER 4583677 NAME UNKNOWN UNKNOWN BC = SPEECH 00:00:00 INCOMING CALL RINGING 0:02 00:00:02 CALL RELEASED *052511 075703 0076 4595595 UNKNOWN U G *052511 075710 0076 4874 4595595 UNKNOWN U A *052511 075711 0076 4874 4595595 UNKNOWN U R -------- 05/25/11 07:57:10 LINE = 0076 STN = 4874 CALLING NUMBER 4595595 NAME UNKNOWN UNKNOWN BC = SPEECH 00:00:00 INCOMING CALL RINGING 0:08 00:00:01 CALL RELEASED -------- 05/25/11 07:56:41 LINE = 0010 LINE = 0067 BC = EXT CALL FORWARD LINE = 0918 REASO +N = VOIP CALL 00:00:00 OUTGOING CALL DIGITS DIALED 5663 00:00:35 CALL RELEASED -------- 05/25/11 07:57:03 LINE = 0009 LINE = 0073 BC = EXT CALL FORWARD LINE = 0918 REASO +N = VOIP CALL 00:00:00 OUTGOING CALL DIGITS DIALED 5663 00:00:20 CALL RELEASED -------- 05/25/11 07:57:11 LINE = 0008 LINE = 0076 BC = EXT CALL FORWARD LINE = 0918 REASO +N = VOIP CALL 00:00:00 OUTGOING CALL DIGITS DIALED 5663 00:00:34 CALL RELEASED
I don't know how to convert it to Java. Thank you.

In reply to Perl to Java by anengineer

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.