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


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

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

Path csiph.com!usenet.pasdenom.info!gegeweb.org!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail
From Jim Janney <jjanney@shell.xmission.com>
Newsgroups comp.lang.java.programmer
Subject Re: Parse a text file and match more than one line
Date Mon, 02 Apr 2012 16:50:25 -0600
Organization and truth to tell she lights up well
Lines 39
Message-ID <2pvclh3g0e.fsf@shell.xmission.com> (permalink)
References <3e114ac2-7034-4167-8d67-ac869f6643f1@h20g2000yqd.googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset=us-ascii
Injection-Info mx04.eternal-september.org; posting-host="PnllQd880uOddfy6hsxHuQ"; logging-data="4587"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+/8kbo3XDWw8TtBUqRykQc"
User-Agent Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux)
Cancel-Lock sha1:7vSgRzud5TgSX447U76EBGZaER0= sha1:JwXH6umMqaCb5B6jzEv0eN+Wu5o=
Xref csiph.com comp.lang.java.programmer:13322

Show key headers only | View raw


mike <mikaelpetterson@hotmail.com> writes:

> 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?
>
> br,
>
> //mike

If the file is not too large, you can read it all into a single string
and apply a regexp to that.  Otherwise, you've already sketched out a
workable approach.

In the general case, consider using a finite state machine.

-- 
Jim Janney

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