阿龙攻城狮
阿龙攻城狮
  • 发布:2020-11-19 20:08
  • 更新:2020-11-23 16:25
  • 阅读:836

【报Bug】关于正则在 App 端报错问题

分类:uni-app

产品分类: uniapp/App

PC开发环境操作系统: Mac

PC开发环境操作系统版本号: MacOS Mojave 10.15.7

HBuilderX类型: 正式

HBuilderX版本号: 2.9.8

手机系统: 全部

手机厂商: 苹果

页面类型: vue

打包方式: 云端

项目创建方式: HBuilderX

测试过的手机:

华为荣耀,iPhone 11 Pro

示例代码:

let RexStr1 = new RegExp("(?<=<)[^<>]+(?=>)","g");
// let RexStr1 = /(?<=<)[^<>]+(?=>)/g;
this.strList = str.match(RexStr1)

操作步骤:

onLoad

预期结果:

希望可以解决

实际结果:

可以正常运行不报错即可.
拿到 strList 不是 null.

bug描述:

我使用了一个正则:
let RexStr1 = new RegExp("(?<=<)[^<>]+(?=>)","g");
// let RexStr1 = /(?<=<)[^<>]+(?=>)/g;
this.strList = str.match(RexStr1)

在 H5 是可以正常运行的,但是在 App 端似乎不认这个正则。

报错信息如下:
[Vue warn]: Error in onLoad hook: "SyntaxError: Invalid regular expression: /(?<=<)[^<>]+(?=>)/: Invalid group"

found in

---> <Root>
19:59:43.326 [system]SyntaxError: Invalid regular expression: /(?<=<)[^<>]+(?=>)/: Invalid group
at new RegExp (<anonymous>)
at VueComponent.strReplace (eval at ./node_modules/babel-loader/lib/index.js!./node_modules/@dcloudio/vue-cli-plugin-uni/packages/webpack-preprocess-loader/index.js?!./node_modules/@dcloudio/vue-cli-plugin-uni/packages/webpack-preprocess-loader/index.js?!./node_modules/@dcloudio/vue-cli-plugin-uni/packages/webpack-uni-app-loader/using-components.js!./node_modules/@dcloudio/vue-cli-plugin-uni/packages/vue-loader/lib/index.js?!./node_modules/@dcloudio/vue-cli-plugin-uni/packages/webpack-scoped-loader/index.js!../../../../../../Users/alonengineer/Downloads/Mad Libs/pages/index/index.vue?vue&type=script&lang=js& (http://localhost:8081/pages-index-index.64af72f5fe6e34c107b9.hot-update.js:11:1), <anonymous>:61:21)
at VueComponent.onLoad (eval at ./node_modules/babel-loader/lib/index.js!./node_modules/@dcloudio/vue-cli-plugin-uni/packages/webpack-preprocess-loader/index.js?!./node_modules/@dcloudio/vue-cli-plugin-uni/packages/webpack-preprocess-loader/index.js?!./node_modules/@dcloudio/vue-cli-plugin-uni/packages/webpack-uni-app-loader/using-components.js!./node_modules/@dcloudio/vue-cli-plugin-uni/packages/vue-loader/lib/index.js?!./node_modules/@dcloudio/vue-cli-plugin-uni/packages/webpack-scoped-loader/index.js!../../../../../../Users/alonengineer/Downloads/Mad Libs/pages/index/index.vue?vue&type=script&lang=js& (http://localhost:8081/pages-index-index.64af72f5fe6e34c107b9.hot-update.js:11:1), <anonymous>:29:10)
at invokeWithErrorHandling (http://localhost:8081/static/js/chunk-vendors.js:5210:26)
at VueComponent.push../node_modules/@dcloudio/vue-cli-plugin-uni/packages/h5-vue/dist/vue.runtime.esm.js.Vue.__call_hook (http://localhost:8081/static/js/chunk-vendors.js:11952:17)
at r (http://localhost:8081/static/js/chunk-vendors.js:98:385335)
at a (http://localhost:8081/static/js/chunk-vendors.js:98:385977)
at VueComponent.created (http://localhost:8081/static/js/chunk-vendors.js:98:16884)
at invokeWithErrorHandling (http://localhost:8081/static/js/chunk-vendors.js:5210:57)
at callHook (http://localhost:8081/static/js/chunk-vendors.js:7616:7)

2020-11-19 20:08 负责人:无 分享
已邀请:
DCloud_UNI_LXH

DCloud_UNI_LXH

在有些环境下,不支持正则的这种写法 (?<=...)

该问题目前已经被锁定, 无法添加新回复