$re = '/(\*\h*\[(?:x| )\])\h*(\w*)/';
$str = '* [x] homepage_url
* [x] description_good
* [x] interact
* [x] contribution
* [x] contribution_requirements
* [x] floss_license
* [x] floss_license_osi
* [x] license_location
* [x] documentation_basics
* [x] documentation_interface
* [x] sites_https
* [x] discussion
* [x] english
* [x] repo_public
* [x] repo_track
* [x] repo_interim
* [x] repo_distributed
* [x] version_unique
* [x] version_semver
* [x] version_tags
* [x] release_notes
* [ ] release_notes_vulns (@marmarek: Are QSBs always mentioned in release notes?)
* [x] report_process
* [x] report_tracker
* [x] report_responses
* [x] enhancement_responses
* [x] report_archive
* [x] vulnerability_report_process
* [x] vulnerability_report_private
* [x] build
* [ ] build_common_tools (@marmarek: Does `qubes-builder` use "common tools"?)
* [x] build_floss_tools
* [x] test
* [ ] test_invocation (@marmarek: Please fill in all "test" and "warning" criteria met.)
* [ ] test_most
* [ ] test_continuous_integration
* [ ] test_policy
* [ ] tests_are_added
* [ ] tests_documented_added
* [ ] warnings
* [ ] warnings_fixed
* [ ] warnings_strict
* [x] know_secure_design
* [x] know_common_errors
* [x] crypto_published
* [x] crypto_call
* [x] crypto_floss
* [x] crypto_keylength
* [x] crypto_working
* [x] crypto_weaknesses (arguably `qvm-backup` still passes despite #971)
* [x] crypto_pfs
* [x] crypto_password_storage
* [x] crypto_random
* [x] delivery_mitm
* [x] delivery_unsigned
* [x] vulnerabilities_fixed_60_days
* [x] vulnerabilities_critical_fixed
* [x] no_leaked_credentials
* [ ] static_analysis (@marmarek: Please fill in all "analysis" criteria met.)
* [ ] static_analysis_common_vulnerabilities
* [ ] static_analysis_fixed
* [ ] static_analysis_often
* [ ] dynamic_analysis
* [ ] dynamic_analysis_enable_assertions
* [ ] dynamic_analysis_fixed
Future Criteria
-------------
* [x] installation_common (depends on how this applies to OSes)
* [ ] build_reproducible
* [x] crypto_used_network
* [x] crypto_tls12
* [x] crypto_certificate_verification
* [x] crypto_verification_private
* [ ] hardened_site
* [ ] hardening
';
$subst = "\1 [\2](https://github.com/linuxfoundation/cii-best-practices-badge/blob/master/doc/criteria.md#\2)";
$result = preg_replace($re, $subst, $str);
echo "The result of the substitution is ".$result;
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for PHP, please visit: http://php.net/manual/en/ref.pcre.php