Finding the XML declaration remover in PhpBB?

Any questions involving matching text strings to patterns - the pattern is called a "regular expression."

Moderator: General Moderators

Post Reply
User avatar
JAB Creations
DevNet Resident
Posts: 2341
Joined: Thu Jan 13, 2005 6:44 pm
Location: Sarasota Florida
Contact:

Finding the XML declaration remover in PhpBB?

Post by JAB Creations »

The developers over at PhpBB think I have no right to use an XML declaration the point of completely burying the code that intentionally goes in to the templates to remove it.

It's definitely a string that matches ?xml string and it will remove it regardless of how many times you declare it or what line it is on. Putting a symbol between ? and xml will break this script...but it will also break the declaration. So does anyone have an idea of what PHP syntax might be conjoining the ? and XML strings?
User avatar
GeertDD
Forum Contributor
Posts: 274
Joined: Sun Oct 22, 2006 1:47 am
Location: Belgium

Post by GeertDD »

Code: Select all

// Using capturing parentheses
$str = preg_replace('/(\?).(xml)/', '$1$2', $str);

// Or using lookaround
$str = preg_replace('/(?<=\?).(?=xml)/', '', $str);
First one appears to be faster.
Post Reply