我爱占星网 我爱占星网
首页
编程
java
php
前端
首页 编程 java php 前端

Php检查字符串格式是否正确

Looking for some help on how to validate a string in PHP.

My string contains:

  • 4 NUMBER
  • 1 LETTER
  • 5 NUMBER

all in one entry, so like 1234A12345.

I need to make sure/validate this before inserting in the DB.

Can one of the wizard help me out there?

This is a pretty simple regex:

/^\d{4}[a-zA-Z]\d{5}$/

And in case you haven't used regex in PHP before.

近期文章

  • result.success失败的ajax调用
  • 如何从php中的url获取数据
  • 使用array_count_values计算数组
  • 检测两个数字范围是否发生冲突
  • 隐藏活动菜单项的下拉列表
  • 使用一个表来更新另一个SQL
  • 创建AR模型实例的范围
  • PHP 5.4.11中的DateTime问题[关闭]
  • PHP会话未设置,没有错误
  • Php在表中添加提交的值
  • 解密与openssl无法正常工作
  • 如果没有价格,PHP添加符号
  • 会话超时和自动重定向
  • 如何解析数组中返回的JSON?
  • 在Code Igniter中嵌套控制器
  • 退出并在PHP / HTML中显示错误消息
  • PHP mb_strpos空响应,中文
  • 如何在MySQL中查找所有子行?
  • 投票百分比计算错误[重复]
  • 有关远程测试服务器的问题

Copyright ©2022 我爱占星 All Rights Reserved.

浙ICP备2022030071号-1

部分图文来自网络,如有侵犯您的版权,请告诉我们删除

友情链接:代码精华