Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #13321

Re: Parse a text file and match more than one line

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!usenet.ukfsn.org!not-for-mail
From Martin Gregorie <martin@address-in-sig.invalid>
Newsgroups comp.lang.java.programmer
Subject Re: Parse a text file and match more than one line
Date Mon, 2 Apr 2012 22:09:43 +0000 (UTC)
Organization UK Free Software Network
Lines 45
Message-ID <jld837$v14$1@localhost.localdomain> (permalink)
References <3e114ac2-7034-4167-8d67-ac869f6643f1@h20g2000yqd.googlegroups.com>
NNTP-Posting-Host 84.45.235.129
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8
Content-Transfer-Encoding 8bit
X-Trace localhost.localdomain 1333404583 31780 84.45.235.129 (2 Apr 2012 22:09:43 GMT)
X-Complaints-To usenet@localhost.localdomain
NNTP-Posting-Date Mon, 2 Apr 2012 22:09:43 +0000 (UTC)
User-Agent Pan/0.135 (Tomorrow I'll Wake Up and Scald Myself with Tea; GIT 30dc37b master)
Xref csiph.com comp.lang.java.programmer:13321

Show key headers only | View raw


On Mon, 02 Apr 2012 04:36:56 -0700, mike wrote:

> Hi,
> 
> I am trying to figure out how to use regexp in java to match this
> pattern:
> 
> 
> compile:
>     [javac] Compiling 933 source files to /tmp/gdduser/classes
> 
> dft.properties:
> 
> So I want to make sure I have:
> 
> compile:
>     [javac] Compiling 933 source files to /tmp/gdduser/classes
> <<nothing on this line>>
> 
> How can I use java to apply it? It will be something like, when
> "compile:" is found check that there is a [javac] Compiling .... on next
> line . If there is then I need to check if there is an empty line. If
> all conditions are fullfilled then I can I know that my build step is
> completed and I have a full match.
> 
> Any ideas?
>
Write some code, test it against a saved example of the logfile you want 
to scan, and if you can't get it to do the job, post an SSCCE here. In 
fact, writing an SSCCE as your first attempt would be a good idea. Look 
here to find out about writing one: http://pscode.org/sscce.html

I'd probably start by testing regexes with "grep -P" and then make them 
work as Java code. If dealing with multi-line regex matching got messy 
due to the need to work inside a sliding three line window, I might try 
generating a lexical parser with the Coco/R package, though it is 
somewhat of a sledge-hammer for this particular nut: its a tool I'm happy 
to use because I'm familiar with BNF grammar notation though it could be 
quite a learning curve if you're not.
   

-- 
martin@   | Martin Gregorie
gregorie. | Essex, UK
org       |

Back to comp.lang.java.programmer | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Parse a text file and match more than one line mike <mikaelpetterson@hotmail.com> - 2012-04-02 04:36 -0700
  Re: Parse a text file and match more than one line Knute Johnson <nospam@knutejohnson.com> - 2012-04-02 14:43 -0700
  Re: Parse a text file and match more than one line Martin Gregorie <martin@address-in-sig.invalid> - 2012-04-02 22:09 +0000
  Re: Parse a text file and match more than one line Jim Janney <jjanney@shell.xmission.com> - 2012-04-02 16:50 -0600
    Re: Parse a text file and match more than one line Jim Janney <jjanney@shell.xmission.com> - 2012-04-02 20:57 -0600
  Re: Parse a text file and match more than one line Roedy Green <see_website@mindprod.com.invalid> - 2012-04-02 15:53 -0700
  Re: Parse a text file and match more than one line Arne Vajhøj <arne@vajhoej.dk> - 2012-04-02 20:08 -0400

csiph-web