Skip to content

Instantly share code, notes, and snippets.

@aereal
Created June 17, 2024 08:14
Show Gist options
  • Save aereal/85ed880e4fab34189c404cb306b9790e to your computer and use it in GitHub Desktop.
Save aereal/85ed880e4fab34189c404cb306b9790e to your computer and use it in GitHub Desktop.
about regular expression's word boundary implementations
if (/\b姉/.test("兄 姉")) console.log("javascript")
say q{perl} if qq{兄 姉} =~ m/\b姉/
puts :ruby if /\b姉/ =~ %q{兄 姉}
@aereal
Copy link
Author

aereal commented Jun 17, 2024

result
[2024-06-17 17:15:21] ✘╹◡╹✘ < node --version
v20.14.0
[2024-06-17 17:15:26] ✘╹◡╹✘ < node -e 'if (/\b姉/.test("兄 姉")) console.log("javascript")'
[2024-06-17 17:15:28] ✘╹◡╹✘ < ruby --version
ruby 3.0.1p64 (2021-04-05 revision 0fb782ee38) [x86_64-darwin19]
[2024-06-17 17:15:37] ✘╹◡╹✘ < ruby -e 'puts :ruby if /\b姉/ =~ %q{兄 姉}'
ruby
[2024-06-17 17:15:40] ✘╹◡╹✘ < perl --version

This is perl 5, version 30, subversion 3 (v5.30.3) built for darwin-thread-multi-2level
(with 2 registered patches, see perl -V for more detail)

Copyright 1987-2020, Larry Wall

Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.

Complete documentation for Perl, including FAQ lists, should be found on
this system using "man perl" or "perldoc perl".  If you have access to the
Internet, point your browser at http://www.perl.org/, the Perl Home Page.

[2024-06-17 17:15:41] ✘╹◡╹✘ < perl -E 'say q{perl} if qq{兄 姉} =~ m/\b姉/'
perl

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment