PHP - regular expression to remove beginning and end chars from a string?
Posted
by John
on Stack Overflow
See other posts from Stack Overflow
or by John
Published on 2010-05-26T21:44:13Z
Indexed on
2010/05/26
21:51 UTC
Read the original article
Hit count: 120
Let's say I have a string like so:
$file = 'widget-widget-newsletter.php';
I want to use preg_replace() to remove the prefix widget-
and to remove the suffix .php
. Is it possible to use one regular expression to achieve all this?
The resulting string should be widget-newsletter
.
© Stack Overflow or respective owner