Find a word in a column then copy the entire row utility?

Soldato
Joined
10 Mar 2003
Posts
6,867
Sounds strange (I know!)

Basically we have a data extract that looks similar to below:

0xxxxxxx332x help sidaiddas8d7u978
0xxxxxxx332x strange sjdfasdsad989
0xxxxxxx332x banana fdsjfdsfsdfdsf

What I need is a utility that will search through the text file find the word 'strange' or whatever and copy that row so the output if I searched for strange would be:

0xxxxxxx332x strange sjdfasdsad989

However this could appear multiple times in the document.

Any ideas?


M.
 
Thanks - Marc2003 would be excellent if I could search for longer strings (say up to 250 characters per line). I'm having a look at findstr now but as a user is going to use it - the PHP version may be better.



M.
 
ok i've changed it so the search box is a textarea also. but i'm guessing you're going to be chucking large amounts of data at it so here's the source so you can put it on your own server. :)

Code:
<?php
if($_POST['submit']) {
        $search = trim($_POST['search']);
	$array = explode("\n", $_POST['data']);
	foreach($array as $value) {
		if(strstr($value, $search)) echo $value.'<br>';
	}
}
?>
<form action="" method="post">
<p><textarea name="data" style="width: 400px; height: 200px;">
Data goes here
</textarea></p>
<p><textarea name="search" style="width: 400px; height: 200px;">
Search string goes here
</textarea></p>
<p><input type="submit" name="submit" value="Submit"></p>
</form>
 
Last edited:
Back
Top Bottom