Re: Syntax highlighting of odd language

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



M. Sokolewicz wrote:
Now, the problem with such a "solution" is the following. Imagine you have the following keywords:
include
require
in
of
typof
now, when you replace include with <span class="highlighted">include</span>, it'll go on, and also replace all instances of in, so you'll end up with things like <span class="highlighted"><span class="highlighted">in</span>clude</span> (very ugly).

I did encounter this during some experimenting. I figured I'd just sort the array of commands from from shortest strong to longest string. But like you said, far too many embedded <span> tags would result!


*a* way to get around that is by using word boundries around the keyword to be replaced (eg. preg_replace('\(\W|^)+('.$highlight[$i].')(\W|$)\i', '$1<span class="highlight">$2</span>$3') )

My regular expression skills are very basic, but I understand the gist of your preg_replace statement. Now I just need to polish my regex knowledge!


Thanks,
--
Aaron Gould
Parts Canada - Web Developer

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux