导航:首页 > 净水问答 > 正则表达式过滤css

正则表达式过滤css

发布时间:2022-05-01 19:41:28

A. 求高手支招:php正则表达式修正css路径问题

preg_replace('/<link(.*?)href=\"(.*?(?:\.css))\"/','<link${1}href=\"theme/$path/${2}\"',$source).

link 和href之间的字符串要保留,同时将css文件路径这块拼凑一下。你写的,就默认link和href之间是一个空格。.*?代表任意字符。?:\.css代表以.css结尾。

B. php正则表达式提取CSS文件中所有background-position值并乘以1.5倍

<?php

$file = '需要请求的数据'
$data=file_get_contents($file);

preg_match_all('/background[^;]+;/', $data, $matches); //获得background的所有信息
print_r($matches);
$count = count($matches[0]);
for ($i=0; $i <$count ; $i++) {
preg_match_all('/[-0-9]+px/', $matches[0][$i],$ab ); //获得 x ,y
if ($ab[0][0]) {
$x[] = intval($ab[0][0])*1.5; //只要x的值
}

}
print_r($x);
?>

看看是不是你想要的

C. 如何用正则表达式,删除html里面的 css js

在DW里查找:<style>[^"]*</style>,替换为空,查找:style="[^"]*",替换为空。查找:<script>[^"]*</script>替换为空,就可以了。

D. 如何用正则表达式提取CSS中的图片路径

var str="NavBar{width:888px; height:35px; float:left;padding-left:62px; margin-top:1px; background:url(images/menu_bj.jpg) repeat-x; line-height:35px; font-size:12px;}.me{width:100px; height:35px; float:left; color:#FFFFFF; font-weight:bold; background:url(images/menu_homebj.jpg) repeat-x;}"

var arr = str.match(/url\(.+?\)/ig);
for(var i =0; i<arr.length; i++)
{
document.write(arr[i].replace("url(","").replace(")","") + "<br />");
}

E. 求过滤html标签和CSS样式表的正则表达式!

先过滤样式表之后再过滤html标签
过滤样式表用
<STYLE>[/s/S]*<\/STYLE>
然后再用<.[^>]*>过滤其他标签HTML

F. asp.net过滤过滤字符串,求正则表达式,style=“ 任意css样式 ”过滤掉

/style="[^"]*"/
这是正则,把他铺货到的替换成空就好了。

G. 求一个匹配CSS属性的正则表达式

/[^-]+(width[^;]+;)/g;

测试代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title> new document </title>
<meta name="generator" content="editplus" />
<meta name="author" content="" />
<meta name="keywords" content="" />
<meta name="description" content="" />
</head>
<body>
<script language="javascript">
<!--
str ="width : 697px;width : 693px;width:694px;width : 695px;width : 696px; border:1px solid #ccc; border-width:3px;"
re = /[^-]+(width[^;]+;)/g;
alert(str.match(re));

//-->
</script>
</body>
</html>

H. 求获取css样式的js正则表达式

vartestContent='.class1{color:red}.class2{color:blue}';
functiongetCss(className){
varreStr='.'+className+'[s]*{[^}]+?}';
varre=newRegExp(reStr,"gi");
returntestContent.match(re);
}
alert(getCss('class1'));
alert(getCss('class2'));

I. CSS背景图片的正则表达式怎么写

比如url(images/nan_bg_o.jpg)这是背景图的css写法,它的正则表达式如下
VBScript codes=".x{background:url(images/nan_bg_o.jpg);}.xx{}.xxx{background: URL(images/nan_bg_oxx.jpg) ;}"

set rx=new RegExp
rx.IgnoreCase=true
rx.Global=true
rx.Pattern="url\s*\(([^\)]+)\)"
set mc=rx.Execute(s)
for each m in mc
response.Write "<pre>"&m.submatches(0)&"</pre>"
next
set rx=nothing

J. 如何检测SQL注入和CSS攻击漏洞

对于他们的攻击,主要是通过使用正则表达式来做输入检测:

  1. 检测SQL meta-characters的正则表达式 :/(\%27)|(’)|(--)|(\%23)|(#)/ix

    1. 解释:我 们首先检查单引号等值的hex,单引号本身或者双重扩折号。

  2. 修正检测SQL meta-characters的正则表达式: /((\%3D)|(=))[^ ]*((\%27)|(’)|(--)|(\%3B)|(:))/i

    1. 解释: 这个规则首先留意 = 号或它的hex值(%3D),然后考虑零个或多个除换行符以外的任意字符,最后检测单引号,双重破折号或分号。

  3. 典型的 SQL 注入攻击的正则表达式: /w*((\%27)|(’))((\%6F)|o|(\%4F))((\%72)|r|(\%52))/ix

    解释:

    1. w* - 零个或多个字符或者下划线。

    2. (\%27)|’ - 单引号或它的hex等值。

    3. (\%6 F)|o|(\%4 F))((\%72)|r|-(\%52) -‘or’的大小写以及它的hex等值

  4. 检测SQL注入,UNION查询关键字的正则表达式: /((\%27)|(’))union/ix

    1. (\%27)|(’) - 单引号和它的hex等值

    2. union - union关键字

    3. 可以同样为其他SQL查询定制表达式,如 >select, insert, update, delete, drop, 等等.

  5. 检测MS SQL Server SQL注入攻击的正则表达式: /exec(s|+)+(s|x)pw+/ix

    1. exec - 请求执行储存或扩展储存过程的关键字

    2. (s|+)+ - 一个或多个的空白或它们的http等值编码

    3. (s|x) p- ‘sp’或‘xp’字母用来辨认储存或扩展储存过程

    4. w+ - 一个或多个字符或下划线来匹配过程的名称


CSS的检测也主要是正则表达式:

阅读全文

与正则表达式过滤css相关的资料

热点内容
医疗废水排放化粪池 浏览:190
提升管反应器是固定床 浏览:139
qt事件过滤器之鼠标左键双击 浏览:835
springurl参数过滤配置 浏览:757
工业废水出水口怎么样 浏览:639
污水usb池 浏览:74
阁瑞斯汽油滤芯在什么位置 浏览:977
水盟超滤净水器 浏览:327
竹筷树脂筷 浏览:465
挖机下柴油滤芯用什么工具 浏览:235
宁波港口edi用在什么领域 浏览:923
如何下载净水器 浏览:547
河南净水器品牌代理厂商电话多少 浏览:492
石油蒸馏产出物顺序 浏览:892
普瑞斯空气净化器负离子怎么用 浏览:501
超滤反洗与气洗步骤 浏览:997
污水设施验收 浏览:522
德龙咖啡机除垢上海 浏览:756
ro膜多大好 浏览:687
医院超纯水需要什么资质 浏览:963