小编cja*_*cja的帖子

用于rgb值的Javascript正则表达式

我正在尝试获取rgb字符串的各个值.我一直在接近,但我只是撞墙了.我想做这样的事情:

var color = rgb(255, 85, 120);

/// My Regex ///
var rRegex = /^rgb\(\d{3}/;  // Which actually gives me an array of two strings...ugh
var gRegex = ;
var bRegex = ;

var r = color.match(rRegex);
var g = color.match(gRegex);
var b = color.match(bRegex);
Run Code Online (Sandbox Code Playgroud)

我只是想:

/// // I think I can pull these off by Starts With and Ends With anchors... ///
r = 'From "(" to "," ';
g = 'From "," to "," ';
b = 'From …
Run Code Online (Sandbox Code Playgroud)

javascript regex rgb

12
推荐指数
4
解决办法
1万
查看次数

在每个中选择第一个(SQL/PHP)

好吧,我试着忍住并寻找答案,但我需要你们的帮助!我有三个表 - 类别,项目和图像.我已将其设置为将图像链接到特定项目,并且每个项目都有一个类别.我使用两个内部联接来做到这一点(这是正确的吗?)我最终要做的是让PHP回显每个项目的第一个图像,然后我将使用ajax加载其余的图像项目.我看过LIMIT,我确信有一种方法可以轻松地使用PHP和for循环,但我只是难倒!我怎样才能回显每个项目的第一个"文件名"?提前致谢!

表:

CREATE TABLE `category` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(50) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `name` (`name`)
) ENGINE=MyISAM AUTO_INCREMENT=5 DEFAULT CHARSET=latin1;

CREATE TABLE `project` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(50) NOT NULL,
  `caption` text NOT NULL,
  `category` int(11) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=4 DEFAULT CHARSET=latin1;

CREATE TABLE `images` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `filename` varchar(255) NOT NULL,
  `project` int(50) NOT NULL, …
Run Code Online (Sandbox Code Playgroud)

php mysql

5
推荐指数
1
解决办法
277
查看次数

标签 统计

javascript ×1

mysql ×1

php ×1

regex ×1

rgb ×1