首页 \ 问答 \ 正则表达式替换url编码的字符串(Regex replace url encoded string)

正则表达式替换url编码的字符串(Regex replace url encoded string)

我有一个字符串,我想用给定的值替换文本[[signature]] ,但由于它是编码的,文本看起来像%5B%5Bsignature%5D%5D

如何使用正则表达式替换它? 此代码段有效,但仅当字符串未编码时:

$replace = preg_replace('/\[\[signature\]\]/', 'replaced!', $html);

I have a string in which I want to replace the text [[signature]] with a given value, but because it is encoded, the text looks like %5B%5Bsignature%5D%5D.

How do I replace this using a regular expression? This snippet works, but only if the string is not encoded:

$replace = preg_replace('/\[\[signature\]\]/', 'replaced!', $html);

原文:https://stackoverflow.com/questions/39657644
更新时间:2024-02-01 22:02

最满意答案

想象一下,你有一个网站,无论出于何种原因,使用了几十个asp:Calendar控件。

要使用CSS来设置它们的样式,你必须在每个上面设置大量的属性:DayStyle和TitleStyle以及NextPrevStyle以及on和on ...

使用主题将允许您只设置所有这些属性,并将其应用于网站上的每个asp:Calendar。 主题将包含相同的CSS,但也包含如何将CSS应用于服务器控件的声明,这是您不能轻易做到的事情。

当然,正如Brian Hasden已经说过的那样,你可能需要一些生活在主题之外的“全球”CSS(特别是如果你的网站有多个主题)。


Imagine you have a site that, for whatever reason, uses dozens of asp:Calendar controls.

To style them with CSS alone, you'll have to set loads of properties on each one: DayStyle and TitleStyle and NextPrevStyle and on and on...

Using a theme will allow you to set all of those properties just once, and have it apply to every asp:Calendar on the site. The theme would contain the same CSS, but also the declaration of how to apply that CSS to server controls, which is something you can't easily do otherwise.

Of course, as Brian Hasden already said, you'll probably need some "global" CSS that lives outside of the theme (particularly if your site has multiple themes).

相关问答

更多
  • 这里是我一直用于实现ASP.NET MVC中的“主题”的代码: ASP.NET MVC:使用自定义ViewEngine实现主题文件夹 当你能够交换CSS文件来改变主题时,这很好,但是这在很多情况下并不实用。 特别是当每个主题需要有完全不同的布局时。 在这种情况下,您需要更改呈现的CSS和HTML,这就是为什么我编写了上述链接中找到的代码的原因。 Here's my code that I've been using for implementing "Themes" in ASP.NET MVC: ASP. ...
  • 我不会特别寻找ASP.NET的东西(可能不会找到任何反正)。 轻松找到一个好的CSS主题可以在ASP.NET中使用。 以下是我喜欢CSS优点的一些网站: http://www.freecsstemplates.org/ http://www.oswd.org/ http://www.openwebdesign.org/ http://www.styleshout.com/ http://www.freelayouts.com/ I wouldn't bother looking for ASP.NET st ...
  • App_Themes适用于常规ASP.NET,不适用于MVC。 Themes系统建立在ASP.NET的事件模型之上,而事件模型并未在MVC中使用。 App_Themes is for regular ASP.NET, not for MVC. The Themes system is built on top of ASP.NET's event model, which is not used in MVC.
  • 该错误告诉你,你的ASP.NET页面(或母版页)需要有一个标签。 没有它,你不能使用主题。 由于服务器端标题标记不应该依赖于视图状态(因为它们不包含在表单中),它可能仍然有效。 话虽如此,但MVC模式中的主题并不一定很好,所以您应该考虑您是否真的需要它们。 The error is telling you that your ASP.NET page (or master page) needs to have a ta ...
  • 我总是使用StyleManager来组合和缩小我的CSS。 它使用YUI Compressor的.NET端口,并增加了结合样式表的功能,所以它应该按照它的声音来完成你需要的功能。 它还增加了一些不错的功能,如CSS常量,背景图像URL中的波浪号(〜)分辨率,缓存控制等。 I always use StyleManager to combine and minify my CSS. It uses a .NET port of YUI Compressor under-the-hood, and adds t ...
  • 我不相信你可以告诉皮肤不要在其中包含文件,这对我们来说是使用它们的杀手,因为它引用了所有的css文件,而不仅仅是我们需要的文件,我们需要最大的效率。 I do not believe you can tell a skin to not include the files within it, that was the killer for us when it came to using them as it referenced all the css files not just the ones w ...
  • 在每个请求中检索css文件夹中的文件的原因是因为我的网站需要登录并且匿名访问被拒绝。 在我的web.config中,我明确允许所有用户访问App_Themes文件夹,这就是为什么它似乎被缓存了。 所以我将以下内容添加到我的web.config中,并且不再需要这些文件。
  • 我不认为你可以。 正是出于这个原因,我们停止使用App_Themes文件夹。 这也节省了我们必须在每个css文件前加上一个数字,以便按正确的顺序加载。 I don't think you can. We stopped using the App_Themes folder for exactly that reason. This also saved us having to prefix every css file with a number so they load in the right or ...
  • 我有类似的问题; 您可以设置IIS以为CSS文件添加内容过期标头 ,以便它们永远不会被缓存,或者您可以使用此SO问题中提供的解决方案 您还可以为每个页面添加一个方法,以遍历page.header中的控件(甚至可能在您的Master.Page!中),以执行以下操作: protected override void OnPreRender(System.EventArgs e) { foreach (Control link in Page.Header.Controls ...
  • 想象一下,你有一个网站,无论出于何种原因,使用了几十个asp:Calendar控件。 要使用CSS来设置它们的样式,你必须在每个上面设置大量的属性:DayStyle和TitleStyle以及NextPrevStyle以及on和on ... 使用主题将允许您只设置所有这些属性,并将其应用于网站上的每个asp:Calendar。 主题将包含相同的CSS,但也包含如何将CSS应用于服务器控件的声明,这是您不能轻易做到的事情。 当然,正如Brian Hasden已经说过的那样,你可能需要一些生活在主题之外的“全球” ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。