I need to capitalize in my Rex Capture / matches, say that I want to capitalize the first letter after a hyphen, My Reggae will be something like this:
And my replacement string should be something like this: But this You can use it like this: Or, with an anonymous function (using PHP ver> gt; = 5.3.0): - (.)
- In
preg_replace , I have something like this:
$ string = preg_replace ('/ - (.) / ',' - \ 1 ', $ string);
Preg_replace (and I do not think it helps in changing the case in a backfirst) Suggestion: < P>
$ string = Preg_replace_callback ('# (? & Lt) ; = -) (.) # ', Create_function (' $ matches', 'return strtoupper ($ matches [1]);', $ string);
$ string = preg_replace_callback (' # (? & Lt; = -) (.) # ', Function ($ matches) {return to stropper ($ matches [1]);}, $ string);
Live demo:
No comments:
Post a Comment