gpt4 book ai didi

react-native - React Native regex 导致 iOS 11.2 崩溃

转载 作者:行者123 更新时间:2023-12-04 04:52:42 25 4
gpt4 key购买 nike

说明

该应用程序仅在 iOS 11.2 上崩溃给我 unhandled JS Exception: Invalid regular expression: unrecognized character after (?而不是在 Debug模式。
我已经在 iOS 13 上测试了相同的代码,它运行良好。我最终弄清楚是哪个正则表达式导致了问题,我发现所有这种类型的正则表达式 (?<value>\d{2}\/\d{2}\/\d{4})导致崩溃,它们作为 Javascript 对象的值存储在单独的 .js 文件中。我要求一种不需要更改所有正则表达式的解决方案。

我不明白为什么 iOS 13 上的行为与 iOS 11.2 不同。

此外,我在此链接 Crash if not in debug on android and iOS 上发现了与lookbehind regex 类似的问题。 .

我已经尝试过的

  • 首先我尝试将 React Native 更新到最新版本
    0.61.5 版,但它没有解决我的问题
  • 我试图在一个全新的项目中复制同样的问题,但它没有崩溃
  • 试图删除所有正则表达式,这奏效了,但正则表达式是应用程序的一个重要而重要的功能的一部分

  • 环境
    System:
    OS: macOS 10.15.2
    CPU: (8) x64 Intel(R) Core(TM) i7-8559U CPU @ 2.70GHz
    Memory: 461.18 MB / 16.00 GB
    Binaries:
    Node: 13.3.0 - /usr/local/Cellar/node/13.3.0/bin/node
    Yarn: 1.19.2 - /usr/local/bin/yarn
    npm: 6.13.4 - /usr/local/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
    SDKs:
    iOS SDK:
    Platforms: iOS 13.2, DriverKit 19.0, macOS 10.15, tvOS 13.2, watchOS 6.1
    Android SDK:
    API Levels: 28, 29
    Build Tools: 28.0.3, 29.0.2
    System Images: android-29 | Google APIs Intel x86 Atom, android-29 | Google Play Intel x86 Atom
    IDEs:
    Android Studio: 3.5 AI-191.8026.42.35.5977832
    Xcode: 11.3/11C29 - /usr/bin/xcodebuild
    npmPackages:
    react: 16.8.6 => 16.8.6
    react-native: ^0.60.5 => 0.60.5
    npmGlobalPackages:
    react-native-cli: 2.0.1

    截图

    iPhone 6s simulator running iOS 11.2

    感谢阅读 🤞

    最佳答案

    我的建议是,如果您发现它不适用于某些特定的 ios 版本,请检查 ios 版本,以及它的 ios 13 及更高版本是否使用该正则表达式或尝试其他一些适用于 11.2 的正则表达式。

    您可以通过以下方式检查 iosVersion

        import {Platform} from 'react-native';

    const majorVersionIOS = parseInt(Platform.Version, 10);
    if (majorVersionIOS <= 13) {
    console.log('YOu need some other regex');
    } else {
    console.log('YOu can use same regex');
    }

    希望能帮助到你。随意怀疑

    关于react-native - React Native regex 导致 iOS 11.2 崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59585179/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com