react native 使用正则踩坑

309 阅读1分钟

判断是否图片类型

    //  验证是否为图片
    IsImg(file){
        // let reg=/(.*)\\.(jpg|bmp|gif|ico|pcx|jpeg|tif|png|raw|tga|PNG|JPG|JPEG)$/;
        let reg=/\.(jpg|gif|jpeg|PNG|JPG|JPEG)+$/ 
        return reg.test(file)
    //    console.log('验证是否为图片',reg.test(file))
    }

exec、match、test等使用正则表达式的函数区别

123.webp