Re: regex, negations, grep, find and replace (a few questions)
- From: "jameshanley39@xxxxxxxxxxx" <jameshanley39@xxxxxxxxxxx>
- Date: 26 Nov 2007 11:49:09 GMT
Moe Trin wrote:
On Sun, 25 Nov 2007, in the Usenet newsgroup alt.os.linux, in article
<bd3885ea-1f0f-4437-88bb-70962513b3de@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>,
jameshanley39@xxxxxxxxxxx wrote:
NOTE: Posting from groups.google.com (or some web-forums) dramatically
reduces the chance of your post being seen. Find a real news server.
hmm, that points out an interesting reason to use a news reader-
filters for removing spam.
ok, I just switched to my news reader. Though a reason I was on google
was since I am posting from a new [windows] user account. The news
reader has all its settings fresh. So for every newsgroup I post to, I
have to add the newsgroup [again]. No big deal, but a bit boring in a
GUI.
Is there anything like grep that does not have this problem/feature
? or where that problem/feature can be turned off?
Problem is the multi-line thing. Generally, I'll convert things to a
large single line - how depends STRONGLY on the format of the file I'm
searching through. But look at 'awk' and 'sed' and the fact that
you can use addressing. Another technique for multi-line searches
would be to use grep to find (example) the 'http' key, and use the
'-A 1' option to grab this AND the following line - then slip the
result through 'tr' to delete the embedded newline, then sed, or cut
to strip out the desired pattern.
I heard that it is hard to negate a regex.
No where near enough information.
well, if one/I/"you" wanted to match NOT "hello world" , using a regex.
I do not know much regex. But it seems as if you define each character
individually. Except with * which defines many, and since . means any,
so .* defines a string of any.
it seems like you can only negate characters. or many of certain
characters.
If you are saying NOT hello. you really want to say NOT (h followed by
e, followed by l.......)
Then neither of these will do it
[^hello] (no order is specified there, it is an OR. on one character
it is just a NOT(A OR B OR C)
And tihs will not do it either
[^h][^e][^l][^l][^o]...
it defines an order but is some very strict thing which will come out
FALSE.
Apparently it is hard, and ugly too, moreso for a long string, to say
NOT (h followed by e, .....)
note- i have a program called regex coach in windows. If you heard of
it, do you know of a linux equivalent, or more appropriate linux
program? It shows you if a regex pattern matches some target string,
and updates itself each time you enter a new character into the regex
pattern or target string. It highlights the match(es).
<snip other useful things>
--
.
- Follow-Ups:
- References:
- regex, negations, grep, find and replace (a few questions)
- From: jameshanley39@xxxxxxxxxxx
- Re: regex, negations, grep, find and replace (a few questions)
- From: Moe Trin
- regex, negations, grep, find and replace (a few questions)
- Prev by Date: Re: Running Slackware from USB
- Next by Date: Re: Beagle chewing up CPU!
- Previous by thread: Re: regex, negations, grep, find and replace (a few questions)
- Next by thread: Re: regex, negations, grep, find and replace (a few questions)
- Index(es):
Relevant Pages
|