regex, negations, grep, find and replace (a few questions)



Here is a regex to match a link. Testing the regex using echo and
piping it
$ echo "abc<a href=\"http://www.blah.com\";>click here</a>" | grep -P
'<a href="http://www.*>.*</a>'

a)
A problem is that grep works line by line. So
- it includes the abc before the link
- if the pattern/link were broken over 2 lines, it would not match
(other tests suggest that)

I really don`t want it to include the abc at the beginning of the line
where the pattern matches.

Is there anything like grep that does not have this problem/feature ?
or where that problem/feature can be turned off?

b)
I heard that it is hard to negate a regex.
So, alternatives,
some programming languages provide advanced features to negate it.
Also, programs, like grep, allow you to negate it. (grep -v)

But grep does not let you do a replace. And On the negation of a
regex.
Which programs would , and how?


Thanks. Sorry if this is not the appropriate newsgroup. If it is not,
then please let me know which is, and I will post it there.



..
.



Relevant Pages

  • Re: Regex Question
    ... Both of these are in a file (named "regex") on two different lines. ... My understanding of alternation is that it will look both for what is on the right and left of the pipe. ... grep in|hill regex ... This requires exactly one backslash in front of the pipe symbol, to prevent the shell from interpreting it. ...
    (Debian-User)
  • Re: Issue with grep -i (on i386 only?)
    ... I tried a few different machines and the 64-bit 7.2 machine I could steal doesn't seem to be affected and out performs pcregrep. ... PCRE provides a POSIX-compliant interface to deal with Perl-compatible regex for those, who are already familiar with the former but it's still Perl regex and not POSIX! ... So here the optimization does not fly. ... In the grep case, the BSDL version is ready and feature-complete but the performance isn't quite satisfying. ...
    (freebsd-hackers)
  • Re: Issue with grep -i (on i386 only?)
    ... Perl-compatible regex for those, who are already familiar with the ... just rewriting the expression is an optimization grep could ... So here the optimization does not fly. ... this is the most important issue with BSDL texttools. ...
    (freebsd-hackers)
  • Re: EOL Anchor under Windows
    ... PL has a regex library, ... If "abc" is a matched string, then grep may be trying to match to ... I would think that most greps consider the "system" EOL as EOL. ...
    (comp.programming)
  • Re: EOL Anchor under Windows
    ... PL has a regex library, ... If "abc" is a matched string, then grep may be trying to match to ... I would think that most greps consider the "system" EOL as EOL. ...
    (comp.lang.perl.misc)