enclose code and testfile.
kline at thought.org
Sun Jun 7 22:41:01 UTC 2009
On Sun, Jun 07, 2009 at 04:52:10PM -0400, Karl Vogel wrote:
> >> On Sat, 6 Jun 2009 18:22:00 -0700,
> >> Gary Kline <kline at thought.org> 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 <TAGS>, </TAGS> 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.
> #!/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.
> 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 at freebsd.org mailing list
> To unsubscribe, send any mail to "freebsd-questions-unsubscribe at freebsd.org"
Gary Kline kline at thought.org http://www.thought.org Public Service Unix
For FBSD list: http://transfinite.thought.org/slicejourney.php
The 4.91a release of Jottings: http://jottings.thought.org/index.php
More information about the freebsd-questions