Solved

Unknown modifier 't'

Posted on 2011-09-20
3
357 Views
Last Modified: 2012-06-22
Hi, I'm getting following error, I'm not really sure why:
Warning: preg_replace() [function.preg-replace]: Unknown modifier 't' in /include/functions.php on line 2084

This is following line:

$url_query = preg_replace('/(.*?)/strona-([0-9]*)-/', '$1/strona-'.$counter.'-', $targetpage); 

Open in new window


Thanks for any help.
0
Comment
Question by:static86
3 Comments
 
LVL 8

Accepted Solution

by:
ropenner earned 167 total points
ID: 36570704
you need to escape the /strona because your delimiter is /

so

$url_query = preg_replace('/(.*?)\/strona-([0-9]*)-/',.....

or use a different delimiter
0
 
LVL 35

Assisted Solution

by:Terry Woods
Terry Woods earned 167 total points
ID: 36570711
Alternatively, you can use different pattern delimiters:
$url_query = preg_replace('#(.*?)/strona-([0-9]*)-#', '$1/strona-'.$counter.'-', $targetpage);
0
 
LVL 108

Assisted Solution

by:Ray Paseur
Ray Paseur earned 166 total points
ID: 36595288
This function can sometimes be helpful.  
http://us3.php.net/manual/en/function.preg-quote.php

But that said, the choice of the regex delimiter is usually made in such a way that it does not appear in the regex pattern.

See the code snippet for an explanation of what the regex engine is looking at in the line of code.

When you are developing regular expressions (or for that matter any complicated piece of code) a test-driven design is a really useful process.  You can see the thought process that goes into TDD in the article here.
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/A_7830-A-Quick-Tour-of-Test-Driven-Development.html
$regex = '/(.*?)/strona-([0-9]*)-/';

$regex
= '/'        // REGEX DELIMITER
. '(.*?)'    // A GROUP OF ANYTHING OR NOTHING
. '/'        // REGEX DELIMITER (OOPS)
. 'strona'   // A STRING, ETC... BUT 's' IS BEING TREATED AS A MODIFIER SINCE IT COMES AFTER THE REGEX DELIMITER.

Open in new window

0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now