Skip to content

Instantly share code, notes, and snippets.

@walish
Last active July 16, 2018 08:14
Show Gist options
  • Save walish/e8430d21dbf0dbcafdb1bb9a87b3a783 to your computer and use it in GitHub Desktop.
Save walish/e8430d21dbf0dbcafdb1bb9a87b3a783 to your computer and use it in GitHub Desktop.
Encountered Regular Expression Cases
  • Replace wrappers around strings Find string
<\?= __\('(.*)?'\) \?>  // <?= __('必須') ?>

Substitution

<!-- ko i18n: '$1'--><!-- /ko --> //<!-- ko i18n: '必須'--><!-- /ko -->
  • Trim unicode/UTF-8 whitespace in PHP
preg_replace('/^[\pZ\pC]+|[\pZ\pC]+$/u', '', $string);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment