regex, negations, grep, find and replace (a few questions)
- From: "jameshanley39@xxxxxxxxxxx" <jameshanley39@xxxxxxxxxxx>
- Date: Sun, 25 Nov 2007 02:13:30 -0800 (PST)
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.
..
.
- Follow-Ups:
- Prev by Date: Re: Format harddrive with DSL
- Next by Date: Re: Format harddrive with DSL
- Previous by thread: Format harddrive with DSL
- Next by thread: Re: regex, negations, grep, find and replace (a few questions)
- Index(es):
Relevant Pages
|