Tag: replace

如何从string中删除换行符(没有字符!)?

这似乎是一个愚蠢的,但放心,这不是 – 我已经search了所有以及networking的其余部分,为我的问题的答案,并最终find同样不足的“解决scheme”一遍又一遍。 无论如何,这里是: 我将用户input从textarea保存到MySQL数据库(在WordPress环境中,但我相信对这个问题应该不重要)。 它稍后从数据库中检索到显示给站点后端的pipe理员。 当用户用换行符提交文本时(即按Enter键),就会出现问题。 示例string可能如下所示: Dear friends, I just wanted so Hello. How are you guys? I'm fine, thanks! Greetings, Bill string中没有行尾字符(“\ n”,“\ r”等)。 我使用nl2br()来生成HTML输出,但这还不够。 结果是: Dear friends, I just wanted so Hello. How are you guys? I'm fine, thanks!<br /> <br /> Greetings,<br /> Bill 就我所知,它是预期的nl2br()结果,因为插入了标签,不应该首先replace换行符? 但是我需要的格式是这样的: Dear friends, I just […]

如何用JavaScriptreplacestring中的所有点

我想在JavaScriptstring中replace点( . )的所有出现 例如,我有: var mystring = 'okay.this.is.a.string'; 我想得到: okay this is a string 。 到目前为止我尝试过: mystring.replace(/./g,' ') 但是这最终将所有的stringreplace为空格。

PHPstringreplace全字匹配

我想用phpreplace完整的单词 例如:如果我有 $text = "Hello hellol hello, Helloz"; 我用 $newtext = str_replace("Hello",'NEW',$text); 新的文字应该看起来像 新的hello1你好,Helloz PHP返回 NEW hello1 hello,NEWz 谢谢。

如何在.NET中replacestring的*第一个实例?

我想replace给定string中的第一个匹配项。 我怎么能在.NET中完成这个?

我如何使用mySQLreplace()replace多个logging中的string?

我们有一个数据库,其中有一堆logging,其中一列有一些错误的数据,其中一个embedded式编辑器转义了一些本不应该被转义的东西,并且中断了生成的链接。 我想运行一个查询来replace所有logging中的坏字符,但不知道如何去做。 我在MySQL中find了replace()函数 ,但是如何在查询中使用它呢? 例如,如果我想要replacestring&lt; 在所有logging中具有小于尖括号( < )的&lt; 在articleItem列? 它可以在一个单一的查询(即一次select和全部replace),还是我必须做多个查询? 即使是多个查询,我如何使用replace()来replace多个logging上的字段的值?

XSLTstringreplace

我真的不知道XSL,但我需要修复这个代码,我已经减less了它,使其更简单。 我得到这个错误 无效的XSLT / XPath函数 在这条线上 <xsl:variable name="text" select="replace($text,'a','b')"/> 这是XSL <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:inm="http://www.inmagic.com/webpublisher/query" version="1.0"> <xsl:output method="text" encoding="UTF-8" /> <xsl:preserve-space elements="*" /> <xsl:template match="text()" /> <xsl:template match="mos"> <xsl:apply-templates /> <xsl:for-each select="mosObj"> 'Notes or subject' <xsl:call-template name="rem-html"> <xsl:with-param name="text" select="SBS_ABSTRACT" /> </xsl:call-template> </xsl:for-each> </xsl:template> <xsl:template name="rem-html"> <xsl:param name="text" /> <xsl:variable name="text" select="replace($text, 'a', 'b')" /> </xsl:template> </xsl:stylesheet> […]

Java如何用string中的单个空格replace2个或更多空格并删除前后空格

在Java中寻找快速,简单的方法来改变这个string " hello there " 看起来像这样的东西 "hello there" 在那里我用一个空格replace所有这些多个空格,除了我还希望string开始处的一个或多个空格消失。 像这样的东西让我部分在那里 String mytext = " hello there "; mytext = mytext.replaceAll("( )+", " "); 但不完全。

MySQLstringreplace

我有一个包含url(id,url)的列: http://www.example.com/articles/updates/43 http://www.example.com/articles/updates/866 http://www.example.com/articles/updates/323 http://www.example.com/articles/updates/seo-url http://www.example.com/articles/updates/4?something=test 我想将“更新”一词改为“新闻”。 是否可以用脚本来做到这一点?

Javastringreplace不工作

String delimiter = "\\*\\*"; String html = "<html><head></head><body>**USERNAME** AND **PASSWORD**</body></html>"; Map<String, String> mp = new HashMap<String, String>(); mp.put("USERNAME", "User A"); mp.put("PASSWORD", "B"); for (Entry<String, String> entry : mp.entrySet()) { html.replace(delimiter + entry.getKey()+ delimiter, entry.getValue()); } 这通常应该取代这两个string,但它不。 有没有人有一个想法?

awk / sed:如何做一个string的recursion查找/replace?

如何查找和replace以下每个事件: subdomainA.example.com 同 subdomainB.example.com 在/home/www/目录树(recursion查找/replace)下的每个文本文件中。