KBD

Keith Devens .com

Friday, August 29, 2008 Flag waving
A charlatan makes obscure what is clear; a thinker makes clear what is obscure. – Hugh Kingsmill
← A testament to characterCoffeeeeee →

Daily link icon Tuesday, December 16, 2003

Always use the [delimiter] in preg_quote

Always use the [delimiter] form of preg_quote.

← A testament to characterCoffeeeeee →

Comments XML gif

Dennis Pallett (http://blog.nocertainty.com/) wrote:

Why? It's an optional argument, right?

∴ Dennis Pallett | 16-Dec-2003 12:51pm est | http://blog.nocertainty.com/ | #3575

Keith (http://keithdevens.com/) wrote:

Yes, it's optional, but if your regular expression delimiter is '/', and you have a '/' in your string, preg_quote without the [delimiter] argument won't escape it, and preg_quote would basically be useless.

I posted this because I actually did find a bug in someone else's PHP code because he didn't specify the [delimiter]. I have to tell him about his bug as soon as finals are over Smiley

Keith | 16-Dec-2003 1:12pm est | http://keithdevens.com/ | #3576

Dennis Pallett (http://blog.nocertainty.com/) wrote:

Oh, thanks, I didn't know this (still learning PHP) Smiley

∴ Dennis Pallett | 17-Dec-2003 2:31pm est | http://blog.nocertainty.com/ | #3585

Dennis Pallett wrote:

Hehe, just came across this comment again. I'm now wondering why the hell I even asked that question. It's bloody obvious to use the [delimiter] argument. I know a bit more about PHP now Smiley winking

∴ Dennis Pallett | 10-Sep-2005 4:53pm est | #8271

Feel free to post a comment below. Please see my comment policy.

Formatting Rules (No HTML):

  • **bold**, *italic*, _underlined_, --strikeout--
  • "text"="url" creates a link, and URLs are auto-highlighted
  • Blockquote: Like e-mail, begin paragraph with > (greater-than sign)
  • Lists: begin paragraph with *,-, or + (unordered), or # (ordered)
  • Code block: ?!code:language=perl|php|sql|javascript|etc.{\n}...{\n}?!/code

:
(will be your IP address if blank)
: (optional)
(Will not be shown on site)

: (optional)
:

August 2008
SunMonTueWedThuFriSat
 12
3456789
10111213141516
17181920212223
24252627282930
31 



RSS feed RSS feed for Keith's Weblog
Atom feed Atom feed for Keith's Weblog
Weblog archive
Recent comments
  on 2 posts

Recent comments XML

new⇒Johnny Walker Blue Label

Wow, thanks for the scotch review​:D

Lagavulin and Laphroaig are​some of...

Keith: Aug 29, 3:35pm

Girls, please don't get breast implants

Wow, After all this time, the​comments on this page continue to​grow. It wa...

Ajeet: Aug 25, 2:36am

Generated in about 0.274s.

(Used 8 db queries)

mobile phone