我需要捕获每个案例定义,然后捕获相关的php文件名。我已经成功地将这个表达式用于单行项目
$re = 'case [\"|\'](.*?)[\"|\'].*=[\s|\"|\'](.*?\.php)';
我正在使用的字符串是:
//--- the following 2 lines are captured
case 'course_leaders' : $page='admin/p-members/email-leaders.php'; break;
case 'courseDifferences' : $page='admin/p-events/diff.php'; break;
//--- the following two cases are not processed/captured
case 'course_leaders_report' :
wp_enqueue_script( 'crsLeaders'
, plugin_dir_url(__FILE__).'admin/js/jquery.tablesorter.min.js'
, array('jquery') );
$page='admin/p-events/leaders-report.php';
break;
case 'course_listing' :
wp_enqueue_script('courseListingDataTables' //--- name
//--- location of js file relative to this file
, plugin_dir_url(__FILE__).'admin/js/DataTables/datatables.min.js'
, array('jquery') //--- use jquery
);
wp_enqueue_script( 'jquery' );
$page='admin/p-events/list-report.php';
break;
//--- this is being captured
case 'course_program' : $page='admin/p-program/courseProgram.php'; break;
没有捕获course_leaders_report和course_listing(来自regexp101.com)。
Full match 798-866 `case 'courseDifferences' : $page='admin/p-events/diff.php`
Group 1. 804-821 `courseDifferences`
Group 2. 843-866 `admin/p-events/diff.php`
Match 7
Full match 2036-2110 `case 'course_program' : $page='admin/p-program/courseProgram.php`
Group 1. 2042-2056 `course_program`
Group 2. 2077-2110 `admin/p-program/courseProgram.php`