replace

Regex for MS Word for detecting subtitle

不打扰是莪最后的温柔 提交于 2020-01-03 07:02:48
问题 I have a MS Word Documents with its subtitle all in font-size 18px and bold. I want to find them all and replace them with something else. There I use Ctrl+H, enabling wldcards, chossing the font style (fontsize and bold), and use the regex (*{1,}) . However, this regex would find occurrences for every single character. How can I make every whole subtitle as a single occurence? Thanks 回答1: Use a Word wildcard Find/Replace, where: Find = ([!^13]@)^13 Replace = Before Text \1 After text^p and

JavaScript replace lowercase uppercase

橙三吉。 提交于 2020-01-03 05:19:51
问题 I want to replace something (variable -> I call it "x" here) in a text (variable) with 'string'+x+'string'. My code: new_content = content.replace(new RegExp(x,"gi"),'string'+x+'string'); So I want to replace upper and lowercase x and the x in 'string'+x+'string' should be lowercase if the search x is lowercase as well. And the same thing for uppercase. Is there a way like $1 for this situation? 回答1: You can use $& in the replacement string to insert the matched string: new_content = content

Python: Sanitize data in JSON before sending

徘徊边缘 提交于 2020-01-03 04:42:24
问题 I have a JSON file that needs to be sent. Before sending I need to do a validity check and replace some special characters (spaces and dots( . )). The problem is that Python inserts u character before each of my strings, which can't be read by the server. How do I remove the u character and do the data sanitation (character replacement)? Original JSON { "columns": [ { "data": "Doc.", "title": "Doc." }, { "data": "Order no.", "title": "Order no." }, { "data": "Nothing", "title": "Nothing" } ],

JS的trim()方法

五迷三道 提交于 2020-01-03 04:06:58
----------------------------------js去空格--------------------------- 去除字符串左右两端的空格,在vbscript里面可以轻松地使用 trim、ltrim 或 rtrim,但在js中却没有这3个内置方法,需要手工编写。下面的实现方法是用到了正则表达式,效率不错,并把这三个方法加入String对象的内置方法中去。   写成类的方法格式如下:(str.trim();)   <script language="javascript">    String.prototype.trim=function(){    return this.replace(/(^\s*)|(\s*$)/g, "");    }    String.prototype.ltrim=function(){    return this.replace(/(^\s*)/g,"");    }    String.prototype.rtrim=function(){    return this.replace(/(\s*$)/g,"");    }   </script>   写成函数可以这样:(trim(str))   <script type="text/javascript">    function trim(str){ /

js去空格

蓝咒 提交于 2020-01-03 04:06:33
----------------------------------js去空格--------------------------- 去除字符串左右两端的空格,在vbscript里面可以轻松地使用 trim、ltrim 或 rtrim,但在js中却没有这3个内置方法,需要手工编写。下面的实现方法是用到了正则表达式,效率不错,并把这三个方法加入String对象的内置方法中去。   写成类的方法格式如下:(str.trim();)   <script language="javascript">    String.prototype.trim=function(){    return this.replace(/(^\s*)|(\s*$)/g, "");    }    String.prototype.ltrim=function(){    return this.replace(/(^\s*)/g,"");    }    String.prototype.rtrim=function(){    return this.replace(/(\s*$)/g,"");    }   </script>   写成函数可以这样:(trim(str))   <script type="text/javascript">    function trim(str){ /

Matlab tex file specify column delimiters

大憨熊 提交于 2020-01-03 03:31:06
问题 I am creating a tex file in Matlab. The end goal is to create a pdf using latex. I have using following website to check the latex I have is correct latex generator. Everything is fine about from when I have a number that contains comma's for example 5,236,012. The issue comes when I copy the data from the tex file. The column delimiter is set to Commas, how can I change this to Semicolon? 回答1: Use strrep - %%// input_filepath and output_filepath are the filepaths of the %%// input and output

How to merge lines that start with the same items in a text file

笑着哭i 提交于 2020-01-03 02:59:12
问题 I have a text file containing some thousand lines as follows: File: abc: bla1 bla1 bla1... cde: bla bla bla... ghk: bla1 bla1 bla1... lmn: bla bla bla... abc: bla2 bla2 bla2... bcd: bla bla bla... ghk: bla2 bla2 bla2... xyz: bla bla bla... I want to merge all the lines that start with the same items (as 1 and 5, 3 and 7 ) so that I have a new text file like this: New File: abc: bla1 bla1 bla1... * abc: bla2 bla2 bla2... cde: bla bla bla... ghk: bla1 bla1 bla1... * ghk: bla2 bla2 bla2... lmn:

Question mark placeholder

人盡茶涼 提交于 2020-01-02 23:08:16
问题 How can I replace all '?' the variables? Something like: $name = 'test' ; $lname = 'lastTest'; $id = 1 ; ->where ( 'customers.name = ? and customers.lastname = ? and customers.id = ?' , $name , $lname , $id ) ; output: customers.name = 'test' and customers.lastname = 'lastTest' and customers.id = 1 Any ideas? 回答1: I really think you should use a library like PDO, but here is a solution nonetheless: public function where($query) { $args = func_get_args(); array_shift($args); $query = preg

How can I find and replace specific text in a SAS data set?

▼魔方 西西 提交于 2020-01-02 21:56:59
问题 I have a data set with 400 observations of 4 digit codes which I would like to pad with a space on both sides ex. Dataset obs code 1 1111 2 1112 3 3333 . . . 400 5999 How can I go through another large data set and replace every occurrence of any of the padded 400 codes with a " ". ex. Large Dataset obs text 1 abcdef 1111 abcdef 2 abcdef 1111 abcdef 1112 8888 3 abcdef 1111 abcdef 11128888 ... Data set that I want ex. New Data set obs text 1 abcdef abcdef 2 abcdef abcdef 8888 3 abcdef abcdef

replace substring in pandas data frame column

六月ゝ 毕业季﹏ 提交于 2020-01-02 10:59:34
问题 I am working with dataframe that contains column named "raw_parameter_name". In this column i have different string values. Several values are like following pattern "ABCD;MEAN". What i am trying to do is to replace each value "ABCD;MEAN" with "ABCD;X-BAR". Sub string "ABCD" may vary but pattern ";MEAN" is constant i want to replace. Looked into different options using "replace" method but don't know how to replace sub string only and not whole string. Please advise. Thank you in advance 回答1: