Tuesday, 6 August 2013

What's the fastest PCRE to remove everything after a char?

What's the fastest PCRE to remove everything after a char?

Say I have abcdeXqwerXiop I would like to get backabcdeXqwer -- cut the
string at the last occurence of X (not including that last char). what's
the fastest way to do that? My best idea is
preg_replace('/.[^X]+$/', '', $string);

No comments:

Post a Comment