开发者

Preg_Replace using Alphanumeric Strings

Right now, I have a preg_replace query which only works with numbers. I am sure I didn't restrict it to just numbers, any help?

Code For Preg_Replace

v开发者_开发知识库iewedResult = preg_replace('/#!(\d{1,4})/', '<a href="updateMooring.php?Number2=${1}&id='. $id .'">${1}</a>', $viewedResult);

String required to be replaced

012A


\d means 'digit'. If you need more, try with character sets like [0-9A-Z].


If you want to include lowercase and uppercase a-z, 0-9 and underscore (_), you can use word character.

preg_replace('/#!(\w{1,4})/', $str);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜