php - GUID 验证正则表达式失败换行符
问题描述
我正在尝试使用以下行验证 PHP 中的 GUID。
$case_number = "088169ed-7a9d-4f78-b999-170971247642\n";
$GUID_validation_RegEx = '/^[A-Fa-f\d]{8}-[A-Fa-f\d]{4}-[A-Fa-f\d]{4}-[A-Fa-f\d]{4}-[A-Fa-f\d]{12}$/';
print(preg_match($GUID_validation_RegEx, $case_number));
它返回1 (true)
我已将问题范围缩小到以下...
^[A-Fa-f\d]{8}-[A-Fa-f\d]{4}-[A-Fa-f\d]{4}-[A-Fa-f\d]{4}-[A-Fa-f\d]{12}$
^^^ these A-F (if I remove them the new line does not match)
为什么会发生这种情况,我该如何解决?
解决方案
推荐阅读
- ios - 如何将本地 Swift 包作为依赖项添加到框架的 Cocoapods podspec?
- performance - Hashmap 比 string.find 慢?
- python - 在 Python 中 Double 调用 Keras 函数
- reactjs - React 添加多个 recharts 图表会导致调整大小时掉帧
- java - 用于匹配字符串中空格的正则表达式
- python - 当我重新加载页面时,它使用 POST 方法。但是我有一个闪光要在 POST 时触发,它不应该在刷新时显示。我该如何解决
- php - 验证一个日期是否经过另一个日期 - Yii 2
- r - Terra从分类栅格中提取不正确的值
- mysql - 如何添加连接子查询
- reactjs - 如何最好地键入 React 包装器的 TypeScript 集合