doupi3874 2012-01-02 05:00
浏览 24

如何区分SHA1字符串和日期时间字符串?

Basically I have two options:

$one = "fdfeb16f096983ada02db49d46a8154475d700ae";
$two = "2011-12-28 05:20:01";

I need some sort of regex, so that I can detect wether the string follows the pattern in $one, or the pattern in $two

Detect if the string is sha1 or datetime.

What would be the best way to determine this?

Thanks

  • 写回答

5条回答 默认 最新

  • douchang8219 2012-01-02 05:02
    关注
    if (preg_match($one, $string) {
        echo "$string matches $one";
    } else if (preg_match($two, $string) {
        echo "$string matches $two";
    }
    
    评论

报告相同问题?

悬赏问题

  • ¥15 关于用pyqt6的项目开发该怎么把前段后端和业务层分离
  • ¥30 线性代数的问题,我真的忘了线代的知识了
  • ¥15 有谁能够把华为matebook e 高通骁龙850刷成安卓系统,或者安装安卓系统
  • ¥188 需要修改一个工具,懂得汇编的人来。
  • ¥15 livecharts wpf piechart 属性
  • ¥20 数学建模,尽量用matlab回答,论文格式
  • ¥15 昨天挂载了一下u盘,然后拔了
  • ¥30 win from 窗口最大最小化,控件放大缩小,闪烁问题
  • ¥20 易康econgnition精度验证
  • ¥15 msix packaging tool打包问题