Connecting Tech Pros Worldwide Forums | Help | Site Map

eregi

Kill Joy
Guest
 
Posts: n/a
#1: Jul 16 '08
Hi all.

I have a file that stats with
___________________________________
/* Vim-generated file */
//Generated settings file for Vim project.
....
........
___________________________________

I open it with:

___________________________________
$log = file("project_vim.js");

foreach($log as $value){
if(eregi("vim", $value)) {
echo $value."";
}
}
___________________________________


But I match nothing

Why?

Many thanks.

Cheers.

Gius.

Juergen-Bernhard Adler
Guest
 
Posts: n/a
#2: Jul 16 '08

re: eregi


Kill Joy wrote:
Quote:
foreach($log as $value){
if(eregi("vim", $value)) {
echo $value."";
}
}

Hi Gius,

I tried it and it worked for me:
i.e. I duly received these two lines!

???

Cheers

juergen
Juergen-Bernhard Adler
Guest
 
Posts: n/a
#3: Jul 17 '08

re: eregi


Kill Joy wrote:
Quote:
foreach($log as $value){
if(eregi("vim", $value)) {
echo $value."";
}
}

Hi Gius,

I tried it and it worked for me:
i.e. I duly received these two lines:

/* Vim-generated file */
//Generated settings file for Vim project.

???

Cheers

juergen
Kill Joy
Guest
 
Posts: n/a
#4: Jul 17 '08

re: eregi


I have a file generated by an application. If I search on this file I
get nothing.
But if I copy and paste the content of this file into another file,
with the second file
it works. Why?

Cheers.

Gius.

On 17 Lug, 01:03, Juergen-Bernhard Adler <jb.ad...@web.dewrote:
Quote:
Kill Joy wrote:
Quote:
foreach($log as $value){
if(eregi("vim", $value)) {
echo $value."";
}
}
>
Hi Gius,
>
I tried it and it worked for me:
i.e. I duly received these two lines:
>
/* Vim-generated file */
//Generated settings file for Vim project.
>
???
>
Cheers
>
juergen
Curtis
Guest
 
Posts: n/a
#5: Jul 19 '08

re: eregi


Kill Joy wrote:
Quote:
Hi all.
>
I have a file that stats with
___________________________________
/* Vim-generated file */
//Generated settings file for Vim project.
...
.......
___________________________________
>
I open it with:
>
___________________________________
$log = file("project_vim.js");
>
foreach($log as $value){
if(eregi("vim", $value)) {
echo $value."";
}
}
___________________________________
>
>
But I match nothing
>
Why?
>
Many thanks.
>
Cheers.
>
Gius.
First, off, when using regex, don't use POSIX (ereg*), they're slower
and less powerful than PCRE.

Also, from the looks of your code, you don't even need regex:

if ( strstr($value, 'vim') )
echo $value;

If the substring 'vim' exists within $value, the strstr returns true.
It's also case sensitive. If you can ignore case by using stristr,
instead.

Have a look through the String Functions portion of the PHP manual:
<URL:http://php.net/manual/en/ref.strings.php>

Curtis (http://dyersweb.com/)
Closed Thread