replace

jquery: replace text and reset on click

别说谁变了你拦得住时间么 提交于 2020-01-05 08:27:19
问题 I've got a 3 items that are clickable and need to have the text changed on click. the HTML <div class="aaa"> <p class="bbb">Hello</p> </div> <div class="aaa"> <p class="bbb">Hello</p> </div> <div class="aaa"> <p class="bbb">Hello</p> </div> and the jQuery $('.aaa').on("click", function() { $('.bbb', this).text(function(_, oldText) { return oldText === 'Hello' ? 'Goodbye' : 'Hello'; }); return false; }); My problem is I need to 'reset' the text if I click a different item. What do I need for

Objective-C: Substring and replace

二次信任 提交于 2020-01-05 08:04:39
问题 I have a NSString which is a URL. This URL need to be cut: NSString *myURL = @"http://www.test.com/folder/testfolder"; NSString *test = [myURL stringByReplacingCharactersInRange:[myURL rangeOfString:@"/" options:NSBackwardsSearch] withString:@""]; I have this URL http://www.test.com/folder/testfolder and I want that the test variable should have the value http://www.test.com/folder/ , so the testfolder should be cut. So I tried to find the NSRange testfolder to replace it with an empty string

xslt 2.0 how replace $ by escaped dollar (for conversion to LaTeX)

让人想犯罪 __ 提交于 2020-01-05 02:58:25
问题 I am new to XSLT. I googled extensively but couldn't figure out how to do the following: I am transforming XML to LaTeX. Of course, LaTeX needs to escape characters such as $ and #. I tried the following in the replace function but it does not work. (They do work without the replace function.) <xsl:template match="xyz:doc"> \subsubsection{<xsl:value-of select="replace( xyz:headline, '(\$)', '\$1' )"/>} ... </xsl:template> <xsl:template match="xyz:doc"> \subsubsection{<xsl:value-of select=

vue组件重新加载(刷新)

谁说胖子不能爱 提交于 2020-01-05 01:55:45
vue组件重新加载(刷新) 第一种方法:利用v-if控制router-view,在根组件APP.vue中实现一个刷新方法 <template> <router-view v-if="isRouterAlive"/> </template> <script> export default { data () { return { isRouterAlive: true } }, methods: { reload () { this.isRouterAlive = false this.$nextTick(() => (this.isRouterAlive = true)) } } } </script> 然后其它任何想刷新自己的路由页面,都可以这样: this.reload() 这种方法可以实现任意组件的刷新。 第二种方法:路由替换 // replace another route (with different component or a dead route) at first // 先进入一个空路由 vm.$router.replace({ path: '/_empty', }) //then replace your route (with same component) vm.$router.replace({ path: '/student/report',

js刷新页面方法

泄露秘密 提交于 2020-01-05 01:19:17
1.刷新方法列表   最近常遇到js刷新页面的需求,就搜集了一些资料来整理一下常用的方法当做我的学习笔记和大家分享!   1、history.go(0)   2、location.reload()   3、location.replace(location)   4、location.assign(location)   5、window.navigate(location)   6、document.URL=location.href   7、document.execCommand('Refresh') 2.刷新方法解析 1, reload 方法,该方法强迫浏览器刷新当前页面。 语法:location.reload([bForceGet]) 参数: bForceGet, 可选参数, 默认为 false,从客户端缓存里取当前页。true, 则以 GET 方式,从服务端取最新的页面, 相当于客户端点击 F5("刷新") 2, replace 方法,该方法通过指定URL替换当前缓存在历史里(客户端)的项目,因此当使用replace方法之后,你不能通过“前进”和“后退”来访问已经被替换的URL。 语法: location.replace(URL) 通常使用: location.reload() 或者是 history.go(0) 来做。 此方法类似客户端点F5刷新页面

How to replace one set of color 'shades' with another set

本秂侑毒 提交于 2020-01-04 14:07:15
问题 I'm looking for a 'magic' function that will take an image and return a copy but with one set of color shades replaced with another set. e.g. I have a picture of a Red fish: It has various greyscales and Black and White but is essentially various shades of red. I would like to pass it to this 'magic' function and tell it to change its Color.Red shades to equivalent Color.Yellow shades and so on. Just simple (rainbow) colors would be sufficient. I have seen many code snippets here and on the

Can I do a number of string replace in one statement in python

旧城冷巷雨未停 提交于 2020-01-04 14:04:16
问题 I am trying to few junk characters in my string using the following statement: desc = string.replace(desc,'“','"') desc = string.replace(desc,'”','"') desc = string.replace(desc,'·','.') Can I write the above 3 statements in to a single statement or atlease the 1st two statements to a single statement. I can not use any third-party libraries in my project. Edit @unutbu: My String looks like below: This is '“' my teststring '”'. I want to replace unicode with appropriate HTML not the whole

Can I do a number of string replace in one statement in python

依然范特西╮ 提交于 2020-01-04 14:03:45
问题 I am trying to few junk characters in my string using the following statement: desc = string.replace(desc,'“','"') desc = string.replace(desc,'”','"') desc = string.replace(desc,'·','.') Can I write the above 3 statements in to a single statement or atlease the 1st two statements to a single statement. I can not use any third-party libraries in my project. Edit @unutbu: My String looks like below: This is '“' my teststring '”'. I want to replace unicode with appropriate HTML not the whole

Replace a value in a dataframe with the row name

对着背影说爱祢 提交于 2020-01-04 13:04:52
问题 I have a data frame that looks like this: Jill Jimmie Alex Jane Jill 1 0 1 1 Jimmie 0 1 1 0 Alex 0 1 1 0 Jane 1 1 1 0 I want to change every 1 to its corresponding row name, such as this: Jill Jimmie Alex Jane Jill Jill 0 Jill Jill Jimmie 0 Jimmie Jimmie 0 Alex 0 Alex Alex 0 Jane Jane Jane Jane 0 After that, I want to remove all zeros from the data frame and move up the values in the columns. I've tried: # for (i in ibm_data){ # if (ibm_data == 1){ # names <- row.names(i) # ibm_data[ibm_data

PHP replace preceding substrings of some other substring

假装没事ソ 提交于 2020-01-04 09:37:36
问题 Let's say I have this string: $myString = 'aaa = b AND cc = dd OR e = ff_%_g AND hh = iii AND j = k_%_lll ...' I want to check if the substring '_%_' is present, and in that case, I want to replace the previous (and only the previous) '=' by a 'LIKE' . Namely, I want this: $myString = 'aaa = b AND cc = dd OR e LIKE ff_%_g AND hh = iii AND j LIKE k_%_lll ...' I know how to replace all the '=' using strpos() and substr_replace() , but I need to replace only those that precede a '_%_' Any help,