Howdy!
I'm trying to automate editing of a configuration file (custom.conf for GDM). I need to find every line between a line that starts with "" and the next line that starts with "", I want to preserve that line, but then delete all the lines in that configuration section and then insert... (3 Replies)
Hi,
I have a situation where I want to replace some occurrences of ".jsp" into ".html" inside a text file.
For Example:
If a pattern found like <a href="http://www.mysite.com/mypage.jsp"> it should be retained.
But if a pattern found like <a href="../mypage.jsp"> it should be changed to... (4 Replies)
Hello,
file1:
not to be changed
not to be changed
<start>
old stuff
old stuff
old stuff
<end>
not to be changed
not to be changed
file2:
new text
new text
desired output: (3 Replies)
can anyone please help me in the below scenario:
File1:
Hello1
Hello1
i want to use sed to replace multiple occurances of Hello1 in file 1 to welcome.
Thanks a ton for the help (9 Replies)
Hello, guys!
"filename" has blocks with three lines each in this fashion:
93909286
#verified
has one bug
10909286
#unverified
pending
10909286
#unverified
pendingThe above example has duplicate blocks, and I have tried using sed to remove just one block... The... (2 Replies)
Hi,
I would like to use sed to replace NA to x ('s/NA/x/g'), but only in the 5th column of the space delimited text file, nowhere else. How do I go about doing that? Thanks! (1 Reply)
Hi,
I want to use sed to replace " /// " with "///" in a text file. However I am getting error messages when I use sed 's/ /// /////g' input.txt > output.txt. How do I go about doing this in sed?
Input:
219518_s_at 0.000189 ELL3 / SERINC4
Output:
219518_s_at 0.000189 ELL3/SERINC4 (5 Replies)
I have a sample text format as given below
<Text Text_ID="10155645315851111_10155645333076543" From="460350337461111" Created="2011-03-16T17:05:37+0000" use_count="123">This is the first text</Text>
<Text Text_ID="10155645315851111_10155645317023456" From="1626711840902323"... (3 Replies)
Good Day Every one
I have a problem finding and replacing text in some large files that will take a long time to manually edit.
Example text file looks like this
#Example Large Text File
unix
linux
dos
squid
bind
dance
bike
car
plane
What im trying to do is to edit all the... (4 Replies)
Hello Everyone,
I have many files like so:
file1.txt
file2.txt
file3.txt
Within each file I have many lines of random text separated by commas like so:
abcAAA,123,defAA,456777,ghiA,789
jklB,101,mnoBBB,11211,pqrB,13111
stuCC,415,vwxCCCC,161,yzaC,718
I am trying to use SED or AWK to... (4 Replies)
Discussion started by: D3U5X
4 Replies
LEARN ABOUT DEBIAN
text::context::eitherside
Text::Context::EitherSide(3pm) User Contributed Perl Documentation Text::Context::EitherSide(3pm)NAME
Text::Context::EitherSide - Get n words either side of search keywords
SYNOPSIS
use Text::Context::EitherSide;
my $text = "The quick brown fox jumped over the lazy dog";
my $context = Text::Context::EitherSide->new($text);
$context->as_string("fox") # "... quick brown fox jumped over ..."
$context->as_string("fox", "jumped")
# "... quick brown fox jumped over the ..."
my $context = Text::Context::EitherSide->new($text, context => 1);
# 1 word on either side
$context->as_string("fox", "jumped", "dog");
# "... brown fox jumped over ... lazy dog",
Or, if you don't believe in all this OO rubbish:
use Text::Context::EitherSide qw(get_context);
get_context(1, $text, "fox", "jumped", "dog")
# "... brown fox jumped over ... lazy dog"
DESCRIPTION
Suppose you have a large piece of text - typically, say, a web page or a mail message. And now suppose you've done some kind of full-text
search on that text for a bunch of keywords, and you want to display the context in which you found the keywords inside the body of the
text.
A simple-minded way to do that would be just to get the two words either side of each keyword. But hey, don't be too simple minded, because
you've got to make sure that the list doesn't overlap. If you have
the quick brown fox jumped over the lazy dog
and you extract two words either side of "fox", "jumped" and "dog", you really don't want to end up with
quick brown fox jumped over brown fox jumped over the the lazy dog
so you need a small amount of smarts. This module has a small amount of smarts.
EXPORTABLE
get_context
This is primarily an object-oriented module. If you don't care about that, just import the "get_context" subroutine, and call it like so:
get_context($num_of_words, $text, @words_to_find)
and you'll get back a string with ellipses as in the synopsis. That's all that most people need to know. But if you want to do clever
stuff...
METHODS
new
my $c = Text::Context::EitherSite->new($text [, context=> $n]);
Create a new object storing some text to be searched, plus optionally some information about how many words on either side you want. (If
you don't like the default of 2.)
context
$c->context(5);
Allows you to get and set the number of the words on either side.
as_sparse_list
$c->as_sparse_list(@keywords)
Returns the keywords, plus n words on either side, as a sparse list; the original text is split into an array of words, and non-contextual
elements are replaced with "undef"s. (That's not actually how it works, but conceptually, it's the same.)
as_list
$c->as_list(@keywords)
The same as "as_sparse_list", but single or multiple "undef"s are collapsed into a single ellipsis:
(undef, "foo", undef, undef, undef, "bar")
becomes
("...", "foo", "...", "bar")
as_string
$c->as_string(@keywords)
Takes the "as_list" output above and joins them all together into a string. This is what most people want from "Text::Context::EitherSide".
EXPORT
"get_context" is available as a shortcut for
Text::Context::EitherSide->new($text, context => $n)->as_string(@words);
but needs to be explicitly imported. Nothing is exported by default.
SEE ALSO
Text::Context is an even smarter way of extracting a contextual string.
AUTHOR
Current maintainer: Tony Bowden
Original author: Simon Cozens
BUGS and QUERIES
Please direct all correspondence regarding this module to:
bug-Text-Context-EitherSide@rt.cpan.org
COPYRIGHT AND LICENSE
Copyright 2002-2005 by Kasei Limited, http://www.kasei.com/
You may use and redistribute this module under the terms of the Artistic License 2.0.
http://www.perlfoundation.org/artistic_license_2_0
perl v5.10.0 2009-05-04 Text::Context::EitherSide(3pm)