There are strings such as:
Get_post_title
Find_my_article
Such a string, how to replace it with regular: Getposttitle,findmyarticle?
With Explode,array_map (Ucword), such a way has been used. Now want to use the regular to achieve, but not enough skill
How do you spell the regular?
Reply to discussion (solution)
$s = ' get_post_title '; echo preg_replace ('/(^|_) (\w)/E ', ' Strtoupper ("$") ', $s);
$s = ' get_post_title '; echo preg_replace ('/(^|_) (\w)/E ', ' Strtoupper ("$") ', $s);
Thank you, owner. Can you tell me about this regular-style analytical idea?
If this is the string: A,b,c,d becomes ' a ', ' B ', ' C ', ' d '? How do you spell the regular?
This is good, the E attribute is listed in the abolition of the list
$s = ' a,b,c,d '; echo preg_replace_callback ('/(?: ^|,) ([A-z])/', function ($r) {return "' $r [1] '";}, $s);
Thank you. But when I was using JavaScript to do this, it seemed a bit wrong. Please take a little solution.
"Get_post_title". Replace (/(^|_) (\w)/g,function ($) {return $2.touppercase ();}) Returns the result: Get_post_title
Don't know why
This is good, the E attribute is listed in the abolition of the list
$s = ' a,b,c,d '; echo preg_replace_callback ('/(?: ^|,) ([A-z])/', function ($r) {return "' $r [1] '";}, $s);
The result of the operation is not quite right.
I wrote it myself:
$s = ' a,b,c,d '; echo preg_replace_callback ('/(\w)/', function ($r) {return "' $r [1] '";}, $s);