Fork me on GitHub
#shadow-cljs
<
2018-12-08
>
pez08:12:32

I’m running into problems with matching unicode letters with regexps. It works in a Figwheel browser project I have:

(re-seq #"(?u)[\p{L}]+" "adams-äpple")
=> ("adams" "äpple")
But in shadow-cljs, targeting node, I get this:
(re-seq #"(?u)[\p{L}]+" "adams-äpple")
Error: <eval>:1
cljs.core.re_seq.call(null,/[\p{L}]+/u,"adams-\u00E4pple")
                 ^
SyntaxError: Invalid regular expression: /[\p{L}]+/: Invalid escape
    at <eval>:1:18
    at ContextifyScript.Script.runInThisContext (vm.js:50:33)
    at runInThisContext (vm.js:139:38)
    at global.SHADOW_NODE_EVAL (/Users/pez/Projects/calva-fmt/lib/calva_fmt.js:83:30)
    at Object.shadow$cljs$devtools$client$node$node_eval [as node_eval] (/Users/pez/Projects/calva-fmt/.shadow-cljs/builds/calva-fmt-lib/dev/out/cljs-runtime/shadow/cljs/devtools/client/node.cljs:24:1)
    at /Users/pez/Projects/calva-fmt/.shadow-cljs/builds/calva-fmt-lib/dev/out/cljs-runtime/shadow/cljs/devtools/client/node.cljs:48:13
    at Object.shadow$cljs$devtools$client$env$repl_call [as repl_call] (/Users/pez/Projects/calva-fmt/.shadow-cljs/builds/calva-fmt-lib/dev/out/cljs-runtime/shadow/cljs/devtools/client/env.cljs:102:11)
    at Object.shadow$cljs$devtools$client$node$repl_invoke [as repl_invoke] (/Users/pez/Projects/calva-fmt/.shadow-cljs/builds/calva-fmt-lib/dev/out/cljs-runtime/shadow/cljs/devtools/client/node.cljs:46:1)
    at shadow$cljs$devtools$client$node$process_message (/Users/pez/Projects/calva-fmt/.shadow-cljs/builds/calva-fmt-lib/dev/out/cljs-runtime/shadow/cljs/devtools/client/node.cljs:116:5)

pez16:12:21

And in the browser console as well as in node this works:

> "adams-äpple".match(/[\p{L}]+/ug);
[ 'adams', 'äpple' ]

royalaid23:12:09

I wrote a short blog post about CLJS+Shadow+Lambda https://dev.to/royalaid/cljs-s-lambda-697

👍 12