Re: [PHP] Search question ..

2003-07-23 Thread Curt Zirzow
* Thus wrote CPT John W. Holmes ([EMAIL PROTECTED]):
> From: "Curt Zirzow" <[EMAIL PROTECTED]>
> > * Thus wrote James Hatridge ([EMAIL PROTECTED]):
> >
> > preg_match('#\(.*)\#im', $text, $matches):
> 
> I don't think you have to escape the < and > characters, do you? Also,
> what's the 'm' modifier for? (I know what it does, why are you using it
> here?)

hm.. I did that by memory, i could of swore that those were beginning
and ending of word matching characters.  I forgot to put my disclaimer
that it was only an example and not something to be used. I spent maybe
5 seconds thinking what he is looking for.

I used the 'm' when  I should have used the 's'. 

> 
> Also, if there's ever a case where could have
> 
> 
> My Title
> 
> 
> i.e. things spread over multiple lines, then you'll need:
> 
> preg_match('#(.*)#is',$text,$matches);
> 
> or, even better (ungreedy)
> 
> preg_match('#([^<]+)#i',$text,$matches);
> 
> The 's' modifier will allow you to match the title even though it's over
> multiple lines with the first regex example. It's not needed in the second.

This has always been a confusing issue, cept now after reading php
documentation on the reg modifiers. Their description of 's' is
completely different (and easier to understand) than man perlre.

Thanks for clearing that up.

Curt
-- 
"I used to think I was indecisive, but now I'm not so sure."

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Search question ..

2003-07-23 Thread CPT John W. Holmes
From: "Curt Zirzow" <[EMAIL PROTECTED]>
> * Thus wrote James Hatridge ([EMAIL PROTECTED]):
> > I've got a search page written for my web site. I can find the html page
I
> > want by keyword. Now I need to get the title of that page in to a
variable.
> > In other words I have a file name, for example Summerbulletin.html. I
now
> > need to get the line " Summer 2003 " in to a variable.
How do
> > I tell html or PHP what I want? (I hope that I am understandable, I'm
still
> > new at this. )
> >
> > Right now I output the search results in to a chart that shows
> > "Summerbulletin.html". What I would like to show is "Summer 2003".
>
> preg_match('#\(.*)\#im', $text, $matches):

I don't think you have to escape the < and > characters, do you? Also,
what's the 'm' modifier for? (I know what it does, why are you using it
here?)

Also, if there's ever a case where could have


My Title


i.e. things spread over multiple lines, then you'll need:

preg_match('#(.*)#is',$text,$matches);

or, even better (ungreedy)

preg_match('#([^<]+)#i',$text,$matches);

The 's' modifier will allow you to match the title even though it's over
multiple lines with the first regex example. It's not needed in the second.

---John Holmes...


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Search question ..

2003-07-23 Thread Curt Zirzow
* Thus wrote James Hatridge ([EMAIL PROTECTED]):
> Hi all..
> 
> I've got a search page written for my web site. I can find the html page I 
> want by keyword. Now I need to get the title of that page in to a variable. 
> In other words I have a file name, for example Summerbulletin.html. I now 
> need to get the line " Summer 2003 " in to a variable. How do 
> I tell html or PHP what I want? (I hope that I am understandable, I'm still 
> new at this. )
> 
> Right now I output the search results in to a chart that shows 
> "Summerbulletin.html". What I would like to show is "Summer 2003". 

preg_match('#\(.*)\#im', $text, $matches):
 

Curt
-- 
"I used to think I was indecisive, but now I'm not so sure."

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Search question ..

2003-07-23 Thread James Hatridge
Hi all..

I've got a search page written for my web site. I can find the html page I 
want by keyword. Now I need to get the title of that page in to a variable. 
In other words I have a file name, for example Summerbulletin.html. I now 
need to get the line " Summer 2003 " in to a variable. How do 
I tell html or PHP what I want? (I hope that I am understandable, I'm still 
new at this. )

Right now I output the search results in to a chart that shows 
"Summerbulletin.html". What I would like to show is "Summer 2003". 

TIA!

JIM

Jim Hatridge
Linux User #88484
-- 
Our country was colonized by the religious, political, economic, and criminal
rejects of every country in the world. We have been carefully breeding insane, 
obsessive, fanatic lunatics with each other for over 400 years, resulting in 
the glorious strain of humanity known as "Americans". You have to expect 
some... peculiarities. 

Read about new German stamps each quarter:
 http:/www.fecundswamp.net/~hatridge/bulletin


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] search question

2002-11-27 Thread Bryan Koschmann - GKT
On Wed, 27 Nov 2002 [EMAIL PROTECTED] wrote:

|You could try any number of PHP functions, but the best ones would be
|strchr/strstr/stristr (for locating the first occurrence of the string),
|strpos (find the position of the first occurrence), or strrchr (to find the
|last).
|

I was just using something like below. Seems to work to find the string
anywhere in the name. Am I missing something or is it really that simple?

Bryan




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] search question

2002-11-27 Thread Liam . Gibbs
<>

You could try any number of PHP functions, but the best ones would be
strchr/strstr/stristr (for locating the first occurrence of the string),
strpos (find the position of the first occurrence), or strrchr (to find the
last).

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] search question

2002-11-27 Thread Bryan Koschmann - GKT
Hello,

I'm wondering what you all think the best way to "search" for a string is.
I guess its more of a matching (regex I'm thinking) but basically what I
want is this..

I'm outputting some rows of data. If one of the columns of that row
contain a string of text, either beginning, end, or middle, highlight it
with a different row color.

The part I need opinions on is matching the search. Would I just do an
ereg/preg?

Thanks,

Bryan


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php