Ask a Question related to PERL Miscellaneous, Design and Development.
-
Mike Grandmasion #1
Regex to detect patterns that do not start with // or <!--
Hi,
I am trying to write a pattern which will give me all matches in java
files for strings that contain the word "the " but do not start with
//, <!--.
This is my pattern so far,
grep -PRi 'out.print.*?[^/][^/].*?the' * | grep -Pi
'out.print.*?[^\<][^!][^-][^-].*?the'
It sort of works but I was wondering if anyone has suggestions on how
to improve it.
Thanks for any pointers,
Mike
Mike Grandmasion Guest
-
Brush patterns
I am a fashion illustrator and am drawing very detailed sketches of garments for quality specifications. I have designed a pattern brush to simulate... -
HTTP::Proxy - how to detect start and end of URL fetch
Inside HTTP::Proxy, is there a way to detect (via callback) when the fetch of the URL begins and ends? aTdHvAaNnKcSe -
Homemade Patterns
I want to make my own patterns, which I'd figured out how to do in 4.0, but every since I've used 9.0 I've not had success. -
copying patterns
In illustrator 10, Mac. I have a pattern created by a friend. It was in an 8.5x11" box. I needed the final print to be that size. I also wanted to... -
Patterns
Hi ! I've got a simple looking problem, do maybe someone will have simple, short solution for it. I hava a string whis is an expression e.g.:... -
Tad McClellan #2
Re: Regex to detect patterns that do not start with // or <!--
Mike Grandmasion <surfer97301@yahoo.com> wrote:
> if anyone has suggestions on how
> to improve it.
Rewrite it in Perl.
--
Tad McClellan SGML consulting
[email]tadmc@augustmail.com[/email] Perl programming
Fort Worth, Texas
Tad McClellan Guest
-
Abigail #3
Re: Regex to detect patterns that do not start with // or <!--
Mike Grandmasion (surfer97301@yahoo.com) wrote on MMMDCLXIX September
MCMXCIII in <URL:news:75821f06.0309170822.18e25b5a@posting.goo gle.com>:
-- Hi,
--
-- I am trying to write a pattern which will give me all matches in java
-- files for strings that contain the word "the " but do not start with
-- //, <!--.
m{^(?!//|<!--).*the }
-- This is my pattern so far,
--
-- grep -PRi 'out.print.*?[^/][^/].*?the' * | grep -Pi
-- 'out.print.*?[^\<][^!][^-][^-].*?the'
$ perl -w
grep -PRi 'out.print.*?[^/][^/].*?the' * | grep -Pi
String found where operator expected at - line 1, near "PRi 'out.print.*?[^/][^/].*?the'"
(Do you need to predeclare PRi?)
'out.print.*?[^\<][^!][^-][^-].*?the'
String found where operator expected at - line 2, near "Pi
'out.print.*?[^\<][^!][^-][^-].*?the'"
(Missing semicolon on previous line?)
syntax error at - line 1, near "PRi 'out.print.*?[^/][^/].*?the'"
Execution of - aborted due to compilation errors.
$
Well, that doesn't compile.
-- It sort of works but I was wondering if anyone has suggestions on how
-- to improve it.
"sort of works"? Is that like "partially pregnant"?
Abigail
--
perl -we 'print split /(?=(.*))/s => "Just another Perl Hacker\n";'
Abigail Guest
-
Mike Grandmasion #4
Re: Regex to detect patterns that do not start with // or <!--
It is a perl regular expression. That is what the P option
designates. If I wrote it in perl I would have the exact same
results.
[email]tadmc@augustmail.com[/email] (Tad McClellan) wrote in message news:<slrnbmh6n1.82o.tadmc@magna.augustmail.com>.. .> Mike Grandmasion <surfer97301@yahoo.com> wrote:
>>> > if anyone has suggestions on how
> > to improve it.
>
> Rewrite it in Perl.Mike Grandmasion Guest
-
Mike Grandmasion #5
Re: Regex to detect patterns that do not start with // or <!--
> m{^(?!//|<!--).*the }
Yeah I would have though I could negate a grouping like that too but
if I change my pattern from:
'out.print.*?[^/][^/].*?the'
to
'out.print.*?^(//).*?the'
I get no output.
Right it is using a perl regular expression being executed through> -- This is my pattern so far,
> --
> -- grep -PRi 'out.print.*?[^/][^/].*?the' * | grep -Pi
> -- 'out.print.*?[^\<][^!][^-][^-].*?the'
>
> $ perl -w
> grep -PRi 'out.print.*?[^/][^/].*?the' * | grep -Pi
> String found where operator expected at - line 1, near "PRi 'out.print.*?[^/][^/].*?the'"
> (Do you need to predeclare PRi?)
> 'out.print.*?[^\<][^!][^-][^-].*?the'
> String found where operator expected at - line 2, near "Pi
> 'out.print.*?[^\<][^!][^-][^-].*?the'"
> (Missing semicolon on previous line?)
> syntax error at - line 1, near "PRi 'out.print.*?[^/][^/].*?the'"
> Execution of - aborted due to compilation errors.
> $
>
>
> Well, that doesn't compile.
grep on the unix commandline.
No more like thinking you are pregnant with a baby and finding out you> "sort of works"? Is that like "partially pregnant"?
are pregnant with two. My pattern is returing a little more than I
want.
Specifically I get hits on it like this:
out.print("<!--\r\n\t
because I assume that the pattern puts the <!-- into the minimal match
before the ^(<!--) portion.
Mike
Mike Grandmasion Guest
-
Abigail #6
Re: Regex to detect patterns that do not start with // or <!--
Mike Grandmasion (surfer97301@yahoo.com) wrote on MMMDCLXX September
MCMXCIII in <URL:news:75821f06.0309181001.377b455b@posting.goo gle.com>:
:) > m{^(?!//|<!--).*the }
:)
:) Yeah I would have though I could negate a grouping like that too but
:) if I change my pattern from:
:)
:) 'out.print.*?[^/][^/].*?the'
What do you think that matches?
:) to
:)
:) 'out.print.*?^(//).*?the'
:)
:) I get no output.
And that surprises you? ^ matches the beginning of the string, so you
are saying you want to match strings that have something before the
beginning of the string. I don't think there are many such strings.
:) > Well, that doesn't compile.
:)
:) Right it is using a perl regular expression being executed through
:) grep on the unix commandline.
That isn't going to work. You can ask questions about Perl regular
expressions here, but for grep, there are other places.
Abigail
--
A perl rose: perl -e '@}>-`-,-`-%-'
Abigail Guest



Reply With Quote

