我正在尝试使用正则表达式查询MYSQL数据库。我希望获得具有此模式1234X32X12的列下的值。
我写了一些伪代码,但是我不熟悉正则表达式,所以我希望有人能帮我解决这个问题。
代码:
if ($transposed_array[$i][0] starts with number)
{
$sid = regex something /^[0-9]*/
$gid = regex something /X[0-9]*X/
$gid = remove first and last character from $gid
$qid = regex something /[0-9]*$/
$question_text = mysql_query("select question from table where sid = ".$sid." and gid = ".$gid." and qid = ".$qid." limit 1");
$transposed_array[$i][0] = $question_test
}任何帮助都将不胜感激!
发布于 2012-10-25 18:40:35
发布于 2012-10-25 18:41:34
我建议阅读Mysql-手册的适当部分,其中非常详细地介绍了如何执行正则表达式搜索。
发布于 2012-10-25 18:42:00
您可以引用mysql的正则表达式匹配函数。
https://stackoverflow.com/questions/13075058
复制相似问题