Re: vertical word match
| From: | 'Joe Rice' | Date: | Fri, 19 Jul 2002 15:09:55 +0000 |
| Subject: | Re: vertical word match | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-108522@lists.php.net to get a copy of this message | ||
i though i had tried this. but, i just did again and it
still isn't matching. I've read that browsers send
different things for the newline from <textarea> but, i've
tried
Netscape,IE on windows
Netscape, Mozilla on Solaris
I really think what i have should work.
$word gets set to
(.?|\s*|\n*|)r(.?|\s*|\n*|)(.?|\s*|\n*|)e(.?|\s*|\n*|)(.?|\s*|\n*|)d(.?|\s*|\n*|)(.?|\s*|\n*|)
(.?|\s*|\n*|)(.?|\s*|\n*|)a(.?|\s*|\n*|)(.?|\s*|\n*|)p(.?|\s*|\n*|)(.?|\s*|\n*|)p(.?|\s*|\n*|)(.?|\s*|\n*|)l(.?|\s*|\n*|)(.?|\s*|\n*|)e(.?|\s*|\n*|)
(match 0 or 1 of anything | match 0 or more of any white space | match 0 or more of newline)
r
(match 0 or 1 of anything | match 0 or more of any white space | match 0 or more of newline)
e
(match 0 or 1 of anything | match 0 or more of any white space | match 0 or more of newline)
d
(match 0 or 1 of anything | match 0 or more of any white space | match 0 or more of newline)
(match 0 or 1 of anything | match 0 or more of any white space | match 0 or more of newline)
a
and so on...
the only thing i can think of is the "space" between the words that
i'm not matching.
if anyone can help, i would appreciate it.
thanks,
joe
Martin Towell(martin.towell@world.net)@Fri, Jul 19, 2002 at 04:06:03PM +1000:
> try changing the "+"'s with "*"'s
> + = 1 or more
> * = 0 or more
>
> -----Original Message-----
> From: Joe Rice [mailto:riceja@water-melon.net]
> Sent: Friday, July 19, 2002 3:30 PM
> To: php-general@lists.php.net
> Subject: [PHP] vertical word match
>
>
>
> hello,
> any regex gurus?
> i'm trying to match words put into a <textarea>
> that are in the form of a\np\np\l\e
> or any combination of new lines in between, before
> or after.
>
> $answer = "hello\na\np\np\nl\ne\n"; /*from textarea in form*/
> $word = "apple";
> $word = preg_replace("/(.)/","(.?|\s+|\n+|)$1(.?|\s+|\n+|)",$word);
> preg_match("/".$word."/im",$answer,$match)
>
> works.
> but if
>
> $word = "red apple";
> $answer = "r\ne\nd\n\na\np\np\nl\e";
>
> it doesn't match.
>
>
> thanks in advance,
> joe
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
--
How do i get rid of those words in my screen that are coming from you?