本文介绍了如何在PHP中检测字符串是否包含1个大写字母的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为此找不到函数.我假设我需要使用正则表达式?

Couldn't find a function for this. I'm assuming I need to use regex?

在URL至少包含1个大写字母的情况下,我正在尝试在php中进行html重定向.

I'm trying to do html redirects in php in cases where the url contains at least 1 upper case letter.

示例: http://www.domain.com/Michael_Jordan 需要重定向到 http://www.domain.com/michael_jordan -唯一的问题是我似乎找不到脚本来检测是否存在至少1个大写字母.

example: http://www.domain.com/Michael_Jordan needs to be redirected to http://www.domain.com/michael_jordan - only problem is I can't seem to find a script to detect if at least 1 capital letter exists.

推荐答案

某些正则表达式应该可以正常工作,可以使用 [A-Z]

Some regular expression should be able to the work, you can use preg_match and [A-Z]

if(preg_match('/[A-Z]/', $domain)){
 // There is one upper
}

这篇关于如何在PHP中检测字符串是否包含1个大写字母的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-16 07:40