Re: regex, negations, grep, find and replace (a few questions)
- From: pk <pk@xxxxx>
- Date: Mon, 26 Nov 2007 16:25:34 +0100
jameshanley39@xxxxxxxxxxx wrote:
that is really interesting, thanks..Is there anything like grep that does not have this problem/featureUse -o (man grep). For the multi-line problem, just remove the
? or where that problem/feature can be turned off?
newline characters before piping the text to grep, eg
echo $text | tr -d '\n' | grep 'your_pattern'
that -o is ideal (and that tr command also shows me how to convert
windows-->unix , since it just involves removing the CR '\r')
note- that command would return all $text or all the file, since you
missed the -o from grep. But I only know about -o since you mentioned
it! I think you intended to include it.
Of course, it escaped me. The -o has the added benefit that if multiple occurrences of the pattern occur in the same line, grep outputs them separately, eg
$ echo "helloblahhello" | grep -o hello
hello
hello
I actually dealt with this find/replace or extraction problem by using
the regex I mentioned, but with grep -o , making a new file.
Then, since it was intented html code I used an old feature of MS Word,
which is probably in linux`s Open Office too. I made the font Courier
(a fixed width font). I held ALT and highlighted in a rectangle, what
I wanted to select, and removed characters i did not want from each
link in one go. I made the font size tiny and the zoom high, to
remove wordwrap.
With OO you can do search/replaces using regexes, something that office cannot do (and won't likely do in the future either, imho).
.
- References:
- regex, negations, grep, find and replace (a few questions)
- From: jameshanley39@xxxxxxxxxxx
- Re: regex, negations, grep, find and replace (a few questions)
- From: pk
- Re: regex, negations, grep, find and replace (a few questions)
- From: jameshanley39@xxxxxxxxxxx
- regex, negations, grep, find and replace (a few questions)
- Prev by Date: Re: regex, negations, grep, find and replace (a few questions)
- Next by Date: Re: regex, negations, grep, find and replace (a few questions)
- 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
|