From owner-freebsd-questions@FreeBSD.ORG Sun Jun 7 22:41:01 2009 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 78FFE106566B for ; Sun, 7 Jun 2009 22:41:01 +0000 (UTC) (envelope-from kline@thought.org) Received: from aristotle.thought.org (aristotle.thought.org [209.180.213.210]) by mx1.freebsd.org (Postfix) with ESMTP id 180348FC14 for ; Sun, 7 Jun 2009 22:41:00 +0000 (UTC) (envelope-from kline@thought.org) Received: from thought.org (tao.thought.org [10.47.0.250]) (authenticated bits=0) by aristotle.thought.org (8.14.2/8.14.2) with ESMTP id n57MgAEI053963; Sun, 7 Jun 2009 15:42:11 -0700 (PDT) (envelope-from kline@thought.org) Received: by thought.org (nbSMTP-1.00) for uid 1002 kline@thought.org; Sun, 7 Jun 2009 15:40:56 -0700 (PDT) Date: Sun, 7 Jun 2009 15:40:55 -0700 From: Gary Kline To: Karl Vogel Message-ID: <20090607224055.GA2134@thought.org> References: <20090607012158.GA14286@thought.org> <20090607205210.5A2AFBED4@kev.msw.wpafb.af.mil> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20090607205210.5A2AFBED4@kev.msw.wpafb.af.mil> User-Agent: Mutt/1.4.2.3i X-Organization: Thought Unlimited. Public service Unix since 1986. X-Of_Interest: With 22++ years of service to the Unix community. X-Spam-Status: No, score=-4.4 required=3.6 tests=ALL_TRUSTED,BAYES_00 autolearn=ham version=3.2.3 X-Spam-Checker-Version: SpamAssassin 3.2.3 (2007-08-08) on aristotle.thought.org Cc: freebsd-questions@freebsd.org Subject: Re: enclose code and testfile. X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 07 Jun 2009 22:41:01 -0000 On Sun, Jun 07, 2009 at 04:52:10PM -0400, Karl Vogel wrote: > >> On Sat, 6 Jun 2009 18:22:00 -0700, > >> Gary Kline said: > > G> I'm encloseing a brief C program that skips over php delimiters and a > G> 74-byte test file. Am wondering if there is a better way. > tHanks for your perl script. What I should have added was that I was looking for a better way in C. It needs to fit into my ascii-to-markup program. The function to scotch , is more than a few lines because of error-checking. In addition to a C function that would skip BEGIN and END delimiters, like the one I cobbled together, is one possible with *any* fixed delimiters-- say, 3- or 4- to some reasonable N- characters? My hunch is NO. Or at least nothing very simply for some small N, >= 7. (I'm thinking of the java code blurbs that end in something like "//>" For the php case, I could have used the "<" and ">" delimiters, but thought better of it. gary > #!/usr/bin/perl -w > # skip PHP stuff in a file > > use strict; > my ($prev, $match); > > # slurp up the entire file. > undef $/; > $_ = <>; > > while (s/ > (.*?) # get text that doesn't include delimiters... > (<\?.*?\?>) # ... plus text in ONE set of delimiters... > //xsm) # ... matching across multiple lines > { > $prev = $1; # text before $match = $2; # text inside > print "$prev"; > } > > print "$_\n"; # whatever's left over. > exit(0); > > -- > Karl Vogel I don't speak for the USAF or my company > > Programming is like sex: one mistake and you have to > support for a lifetime. --unknown > _______________________________________________ > freebsd-questions@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-questions > To unsubscribe, send any mail to "freebsd-questions-unsubscribe@freebsd.org" -- Gary Kline kline@thought.org http://www.thought.org Public Service Unix http://jottings.thought.org http://transfinite.thought.org For FBSD list: http://transfinite.thought.org/slicejourney.php The 4.91a release of Jottings: http://jottings.thought.org/index.php