Re: Re: RegEx (back referencing)

From: Date: Mon, 05 Aug 2002 20:58:47 +0000
Subject: Re: Re: RegEx (back referencing)
Groups: php.general 
Request: Send a blank email to php-general+get-111264@lists.php.net to get a copy of this message
>Yeah the « & » are correct. Sorry did not post all of the thread, this is >being done so I can diferentiate between what should be displayed on screen >and what should actually remain HTML. So after doing all the changes for >color coding the various elements of the script, the following lines of code >are used... They might be what's in your string, but Ereg probably doesn't support those funky characters... And they certainly aren't valid HTML characters. Maybe try str_replace, which is much simpler in nature. It might "work" with those invalid characters, though you'll be relying on undocumented behaviour probably... Where the heck are the funky « and » coming from anyway? Is that some weird ColdFusion thing or what? You might have better luck starting with http://php.net/htmlentities and then inserting your FONT color codes after that... Or, look at the PHP source for http://php.net/syntax-highlight and see how the PHP Group did it for PHP itself. Odds are really good you could "steal" their code and get it correct faster than starting from scratch. > >// allow script tags to display >$fcontent = eregi_replace("<", "&lt;", $fcontent); >$fcontent = eregi_replace(">", "&gt;", $fcontent); >$fcontent = eregi_replace("«", "<", $fcontent); >$fcontent = eregi_replace("»", ">", $fcontent); > >This allows all font tags to be HTML and actually display the colour while >everything that is actually part of the script displays. > > >Phil. >> -----Original Message----- >> From: Richard Lynch [mailto:rich@phpbootcamp.com] >> Sent: 05 August 2002 07:43 >> To: phil@n-igma.net >> Cc: php-general@lists.php.net >> Subject: [PHP] Re: RegEx (back referencing) >> >> >> >Hi, >> > >> >I am am writing a function to color code and indent JavaScript >> source using >> >regular expressions and cannot seem to get back referencing working. The >> >pattern match is successful but the output is a single unrecognised >> >character (a square). >> > >> >$string = eregi_replace("<(/?)(scr[^>]*)>", "«font >> color=maroon»\1«/font»", >> >$string); >> > >> >This results in opening and closing <script></script> tags being replaced >> >with a square being wrapped in font tags. I have this working in >> Cold Fusion >> >but cannot seem to convert my scripts to PHP. Can anyone help? >> >> If the « you posted is actually in your source code instead of << it ain't >> gonna work... >> ^ >> / \ >> This is not a valid ASCII character. >> >> >> >> -- >> Like Music? http://l-i-e.com/artists.htm >> I'm looking for a PRO QUALITY two-input sound card supported by Linux (any >> major distro). Need to record live events (mixed already) to stereo >> CD-quality. Soundcard Recommendations? >> Software to handle the recording? Don't need fancy mixer stuff. Zero (0) >> post-production time. Just raw PCM/WAV/AIFF 16+ bit, 44.1KHz, Stereo >> audio-to-disk. >> >> -- >> PHP General Mailing List (http://www.php.net/) >> To unsubscribe, visit: http://www.php.net/unsub.php >> > -- Like Music? http://l-i-e.com/artists.htm I'm looking for a PRO QUALITY two-input sound card supported by Linux (any major distro). Need to record live events (mixed already) to stereo CD-quality. Soundcard Recommendations? Software to handle the recording? Don't need fancy mixer stuff. Zero (0) post-production time. Just raw PCM/WAV/AIFF 16+ bit, 44.1KHz, Stereo audio-to-disk.

« previous php.general (#111264) next »