preg_match_all() failure on search (documentation request)

escoles - August 18, 2008 - 18:54
Project:Search and Replace Scanner
Version:5.x-1.0-alpha2
Component:Documentation
Category:feature request
Priority:minor
Assigned:Unassigned
Status:closed
Description

Something to get to when you get around to polishing this absurdly useful module.

I kept getting the following when I searched:

warning: preg_match_all() [function.preg-match-all]: Unknown modifier ')' in /Users/escoles/Sites/turnerengineering_staging/modules/scanner/scanner.module on line 198

I'd initially done a Replace, but come up with far fewer replacements than there should have been instances of the search string. So I searched, and this is the error that returns. I get about as many instances of this error as I think there should be instances of the search string ("/staging").

My reg exp skills are nearly nonexistant, but the line in question didn't look wrong:

$hits = preg_match_all("/(.{0,8})($search)(.{0,8})/$flag", $content, $matches, PREG_SET_ORDER);

Then it occurred to me I should be escaping the "/". Suddenly all was well.

So if you could document that in some future version, it would be marvy.

Really, this thing is frighteningly powerful. Probably should come with red blink text that says POINT AWAY FROM FACE. (I mean that as a compliment.)

#1

aasarava - November 23, 2008 - 21:00
Status:active» closed

Thanks for the helpful usability and documentation feedback. In version 5.x-2.0, we've made regular expression searches optional, so that you don't have to escape special characters for simple searches.

 
 

Drupal is a registered trademark of Dries Buytaert.