replace

JS转换HTML转义符

强颜欢笑 提交于 2020-02-09 19:40:53
//去掉html标签 function removeHtmlTab(tab) { return tab.replace(/<[^<>]+?>/g,'');//删除所有HTML标签 } //普通字符转换成转意符 function html2Escape(sHtml) { return sHtml.replace(/[<>&"]/g,function(c){return {'<':'<','>':'>','&':'&','"':'"'}[c];}); } //转意符换成普通字符 function escape2Html(str) { var arrEntities={'lt':'<','gt':'>','nbsp':' ','amp':'&','quot':'"'}; return str.replace(/&(lt|gt|nbsp|amp|quot);/ig,function(all,t){return arrEntities[t];}); } //  转成空格 function nbsp2Space(str) { var arrEntities = {'nbsp' : ' '}; return str.replace(/&(nbsp);/ig, function(all, t){return arrEntities[t]}) } //回车转为br标签 function

How to search and replace a string in environment variable PATH?

与世无争的帅哥 提交于 2020-02-09 04:41:49
问题 Is there any command in batch to search and replace a string in environment variable PATH ? For example the contents of environment variable PATH is: C:\windows\system32;C:\windows;C:\windows\System32\Wbem;C:\windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\AccuRev\bin;C:\Python24 I have to search for C:\Python24 in this variable and need to replace it by C:\Python27 . 回答1: Local PATH replacement The solution provided by wmz is perfect: set "PATH=%PATH:Python24=Python27%" For details

18 Replace Elements with Greatest Element on Right Side

烂漫一生 提交于 2020-02-08 18:16:00
题目 Given an array arr, replace every element in that array with the greatest element among the elements to its right, and replace the last element with -1. After doing so, return the array. Example 1: Input: arr = [17,18,5,4,6,1] Output: [18,6,6,6,1,-1] Constraints: 1 <= arr.length <= 10^4 1 <= arr[i] <= 10^5 分析 题意: 遍历数组,将当前数字替换成右侧最大的一个数字 最后将末尾的一个数字替换为-1 i=0 17 18 5 4 6 1 ⇒ 18 18 5 4 6 1 i=1 18 18 5 4 6 1 ⇒ 18 6 5 4 6 1 i=2 18 6 5 4 6 1 ⇒ 18 6 6 4 6 1 i=3 18 6 6 4 6 1 ⇒ 18 6 6 6 6 1 i=4 18 6 6 6 6 1 ⇒ 18 6 6 6 6 1 i=5 18 6 6 6 6 1 ⇒ 18 6 6 6 6 -1 难点: 拿到每个数字时,还得找出其后的最大数,遍历自然能够解决,但是复杂度太高。

How do I change a string line submitted in the form with another form input

[亡魂溺海] 提交于 2020-02-08 07:47:07
问题 In my first page I have this code: $number="1234567891"; $str="456"; echo "<form action='edit.php' method='POST'><input type='hidden' name='msg' value='$message' /> <input type='hidden' name='text' value='$number' /> <input type='hidden' name='edit' value='$str' /> <input type='submit' name='chedit' value='Go' style='position:relative; top:25px; left: 50%;'> </form>"; In my edit.php I have this code: <form action="#" method="POST"> Edit Number <input type="text" name="change" value="$mumu"/>

How do I change a string line submitted in the form with another form input

一笑奈何 提交于 2020-02-08 07:46:07
问题 In my first page I have this code: $number="1234567891"; $str="456"; echo "<form action='edit.php' method='POST'><input type='hidden' name='msg' value='$message' /> <input type='hidden' name='text' value='$number' /> <input type='hidden' name='edit' value='$str' /> <input type='submit' name='chedit' value='Go' style='position:relative; top:25px; left: 50%;'> </form>"; In my edit.php I have this code: <form action="#" method="POST"> Edit Number <input type="text" name="change" value="$mumu"/>

LC 833. Find And Replace in String

孤者浪人 提交于 2020-02-08 06:01:12
To some string S , we will perform some replacement operations that replace groups of letters with new ones (not necessarily the same size). Each replacement operation has 3 parameters : a starting index i , a source word x and a target word y . The rule is that if x starts at position i in the original string S , then we will replace that occurrence of x with y . If not, we do nothing. For example, if we have S = "abcd" and we have some replacement operation i = 2, x = "cd", y = "ffff" , then because "cd" starts at position 2 in the original string S , we will replace it with "ffff" . Using

833. Find And Replace in String —— weekly contest 84

孤者浪人 提交于 2020-02-08 05:10:15
Find And Replace in String To some string S , we will perform some replacement operations that replace groups of letters with new ones (not necessarily the same size). Each replacement operation has 3 parameters: a starting index i , a source word x and a target word y . The rule is that if x starts at position i in the original string S , then we will replace that occurrence of x with y . If not, we do nothing. For example, if we have S = "abcd" and we have some replacement operation i = 2, x = "cd", y = "ffff" , then because "cd" starts at position 2 in the original string S , we will

LeetCode in C++ 833. Find And Replace in String

寵の児 提交于 2020-02-08 04:56:46
To some string S, we will perform some replacement operations that replace groups of letters with new ones (not necessarily the same size). Each replacement operation has 3 parameters: a starting index i, a source word x and a target word y. The rule is that if x starts at position i in the original string S, then we will replace that occurrence of x with y. If not, we do nothing. For example, if we have S = "abcd" and we have some replacement operation i = 2, x = "cd", y = "ffff", then because "cd" starts at position 2 in the original string S, we will replace it with "ffff". Using another

Add +1 to a string obtained from another site

僤鯓⒐⒋嵵緔 提交于 2020-02-07 05:39:09
问题 I have a string I get from a website. A portion of the string is "X2" I want to add +1 to 2. The entire string I get is: 20120815_00_X2 What I want is to add the "X2" +1 until "20120815_00_X13" 回答1: You can do : $string = '20120815_00_X2'; $concat = substr($string, 0, -1); $num = (integer) substr($string, -1); $incremented = $concat . ($num + 1); echo $incremented; For more informations about substr() see => documentation 回答2: You want to find the number at the end of your string and capture