I have a text file.
I read each line with sr.readline();
as i read that line, i want to search for it in a List that it should have been added to previously, then add it to a NEW list. How do i do this?
When searching for number of occurrences of a string in a file, I generally use:
grep pattern file | wc -l
However, this only finds one occurrence per line, because of the way grep works. How can I search for the number of times a string appears in a file, regardless of whether they are on the same or different lines?
Also, what if I'm searching for a regex pattern, not a simple string? How can I count those, or, even better, print each match on a new line?
Whenever a click event happen on a hyper-link, I will use JavaScript to toggle the display of a drop down menu. However, I realize there will be a dotted line rectangle surrounded the hyper-link still. May I know how I can explicitly remove the dotted line rectangle after the click?
Hello,
Is there a way to read a file in PHP5 from line X to line Y into a string, without reading the entire file.
I would like to return huge files (10,000+ lines) using ajax requests. Each request will provide the client with additional lines. And due to the fact that the file can reach large sizes, I would like to avoid reading it whole over and over again.
Thank you.
I have a script that generates two lines as output each time. I'm really just interested in the second line. Moreover I'm only interested in the text that appears between a pair of #'s on the second line. Additionally, between the hashes, another delimiter is used: ^A. It would be great if I can also break apart each part of text that is ^A-delimited (Note that ^A is SOH special character and can be typed by using Ctrl-A)
I have been searching around, but there seems no good answer for this simple question. So I am asking again: how to animate line-drawing in iphone dev?
Basically what I want is something like this:
@implementation MyUIView
- (void) triggerLineDrawing: (CGPathRef) path {
...
// animate line drawing here
}
Can it be done?
Hi,
I am trying to format this line of code in my popup window, but i am facing unterminated string literal error.
Can somebody please tell me how best I could format this.
window.setTimeout("winId.document.write('<script src="../js/tiny_mce/tiny_mce.js" type="text/javascript"></script>\n')", 10);
Also point out if this particular line of code would work fine in the popup?
I want to write data at a specified value in a text file from a text box. Here is a example:
item_begin etcitem 3344 item_type=etcitem is first line and item_begin weapon 3343 item_type=weapon is second. Well i want to replace item_type=weapon at second line with item_type=armor. Here is code so far:
var data2 = File.WriteAllLines("itemdata.txt")
.Where(x => x.Contains("3343"))
.Take(1)
.SelectMany(x => x.Split('\t'))
.Select(x => x.Split('='))
.Where(x => x.Length > 1)
.ToDictionary(x => x[0].Trim(), x => x[1]);
But returns error at WriteAllLines.
Here is the readline part code:
var data = File.ReadLines("itemdata.txt")
.Where(x => x.Contains("3343"))
.Take(1)
.SelectMany(x => x.Split('\t'))
.Select(x => x.Split('='))
.Where(x => x.Length > 1)
.ToDictionary(x => x[0].Trim(), x => x[1]);
//call values
textitem_type.Text = data["item_type"];
And want to write the same value I change on textitem_type.Text after read.
I used this to reaplace but replaces all values with same name from line and returns me in text only 1 line. Code:
private void button2_Click(object sender, EventArgs e)
{
var data = File
.ReadLines("itemdata.txt")
.Where(x => x.Contains(itemSrchtxt.Text))
.Take(1)
.SelectMany(x => x.Split('\t'))
.Select(x => x.Split('='))
.Where(x => x.Length > 1)
.ToDictionary(x => x[0].Trim(), x => x[1]);
StreamReader reader = new StreamReader(Directory.GetCurrentDirectory() + @"\itemdata.txt");
string content = reader.ReadLine();
reader.Close();
content = Regex.Replace(content, data["item_type"], textitem_type.Text);
StreamWriter write = new StreamWriter(Directory.GetCurrentDirectory() + @"\itemdata.txt");
write.WriteLine(content);
write.Close();
}
I have a makefile that looks like:
default:
lua blah.lua
Now, in vim, I type ":make"
There's an error in my lua code; it gives a file name + line number. I would like vim to jump to the right file/line. How do I make this happen?
Thanks!
Hi everyone ,
count_record=file.readline()
count_prev=count_record[:-1] ,
i used this to read the previous line and it worked but now when i am using
count_next=count_record[:+1] i am not able to read the next line , is there is way to do so read the next time .
Thanks for your help
I am trying to create a multi line string in Groovy. I have a list of strings that I'd like to loop through within the multi line string. I am not sure what the syntax is for this. Something like below...
def html = """\
<ul>
<li>$awaiting.each { it.toPermalink()}</li>
</ul>
"""
How can I set a conditional breakpoint to a function's 3rd line in GDB?
I know I could give the file name + line number but this is not working for me.
I have to store the gdb commands as a script to repeat it later and I don't want to change the script every time the source file is changing.
I have a flex line chart. Instead of the default behavior of having to hover over parts of the line to see the data points, is there a way to change the rendering of each point and have them always displayed? (almost like a connect the dots type view).
Is it possible to create a command line Abode Air app? I know thats not the intended use of the framework, but I have a lot of utility code written in as3, and I have a need to programatically run some utility functions from another app (not flash).
I know I can pass command line parameters to the Air app, but I would like to avoid having a window pop up while the calculations are being made.
Thanks.
I relaly like C's LINE and FILE ... does lua provide something similar? (I find it useful for tracking down printf's ... to know which file and which line the message comes from).
Thanks!
I have a 4MB log file from the Windows XP firewall which I'm trying to find lines that have both DROP and an IP and a port number. My regex-fu is weak and I'm assuming this is the reason I'm struggling.
The words "DROP", "10.1.1.1" (for example) and "8801" need to be found on the same line and may be spread across the line and separated by one or more other words.
Any help (or suggestions of another method to do this) are much appreciated.
Can this be done in 1 line with PHP?
Would be awesome if it could:
$out = array("foo","bar");
echo $out[0];
Something such as:
echo array("foo","bar")[0];
Unfortunately that's not possible. Would it be possible like this?
So I can do this for example in 1 line:
echo array(rand(1,100), rand(1000,2000))[rand(0,1)];
Hello, say I have a paragraph of text, with some new lines/line breaks. I would like to find the occurance of a certain keyword, and return the line numbers of those keywords. How do I do that? Thanks!
Hi
What is the easiest way to have a paragraph with one or with two vertical black lines on its left?
I have something like this so far:
\newcommand{\attention}[1]{\begin{huge}!\end{huge} #1}
But instead of a huge exclamation mark, I want a vertical line, whether the paragraph is one- or multi-line.
Hi friends i am trying to move curser move to the next line. it is worked but when i enter a character in textview curser again back to first line. please help me any one. i am writing below code.` if (textView == mailBodyTxtVew)
{
textView.text= [textView.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
//[textView resignFirstResponder];
// return NO;
}
`
hi
I find way to replace word in text file as the following
strNewText = Replace(strText, "OLD_WORD", "NEW_WORD")t
but this replace every OLD_WORD in the file
my question is if it possible to replace the OLD_WORD with the NEW_WORD only on specific line
for example I want to replace only on line that start with "THIS_LOCATION"
THIS_LOCATION=OLD_WORD
THX for help
My Zend application is going to get an command line php script that should email reports. There generation depends on Zend_View, Zend_Layout and is currently already working fine in the web interface.
How can I reuse this whole MVC functionality in the command line?
Should I add a new controller CommandLineController and call this somehow from the commandline?
How can I kick of such a Controller manually, without having a HTTP request?
I've built a custom logging utility which displays a Log Message and the DateTime. I would like to add the line number in the source code which called the function.
Is there a way to determine which line of the HTML source a particular javascript function was fired?