replace

Multiline string replace with pretty indentation

偶尔善良 提交于 2020-01-16 05:12:31
问题 I want to do multi-line string replacements in some template files, but retain a pretty indentation. Here's an example of the template: <TAG1> <TAG2> %REPLACETHIS% </TAG2> </TAG1> Now, when I simply replace the string %REPLACETHIS% with a string like <REPLACEDSTRINGTAG1> replacedstringtext </REPLACEDSTRINGTAG1> it will look something like: <TAG1> <TAG2> <REPLACEDSTRINGTAG1> replacedstringtext </REPLACEDSTRINGTAG1> </TAG2> </TAG1> when it should look like: <TAG1> <TAG2> <REPLACEDSTRINGTAG1>

How can I replace text in PDF with iText without encoding issue? (Android)

て烟熏妆下的殇ゞ 提交于 2020-01-16 04:37:05
问题 I need some help. I want to replace a text with an another in a PDF file (I'm using iText library), but when I'm trying to do it with accent letters, it has encoding problems. public static void manipulatePdf(String src, String dest) throws IOException, DocumentException { PdfReader reader = new PdfReader(src); PdfDictionary dict = reader.getPageN(1); PdfObject object = dict.getDirectObject(PdfName.CONTENTS); if (object instanceof PRStream) { PRStream stream = (PRStream) object; byte[] data =

If data present, replace with data from another column based on row ID

牧云@^-^@ 提交于 2020-01-16 02:04:09
问题 I would like to replace data in columns rep1 to rep4. The data in these columns match unique ID's in the first column. I want to replace the data in columns rep1-rep4 with data in the value column with the corresponding ID row. So, for the second row "b", I want to replace "a" in the column "rep1" with the corresponding value in row "a", in this case, -400. ID rep1 rep2 rep3 rep4 value a -400 b a -300 c a b -200 d a b c -300 e a b c d -400 f -400 g f -400 h -400 i -200 j k l -300 k l -200 l

How to join two table with partial match

巧了我就是萌 提交于 2020-01-15 23:04:39
问题 I have two table with the following data: TableA.name R4.23-Core-2 R4.23-Core-2 LA#213 CGHPBXsw01 127.213 0024-737e-e341 LA#252 CGHRack1sw01 127.252 0022-57ab-d781 SOC-01A-SW01 to - R4-DISTR-9512 to-R2-DISTR-5900-1 to-R3.25-EDGE TableB.caption R4.23-Core-2.ehd.ca R4.23-Core-2.nhd.ca CGHPBXsw01 CGHRack1sw01 SOC-01A-SW01 R4-DISTR-9512 R2-DISTR-5900-1.phsnc. R3.25-EDGE.phsne.edjc.ca I've tried using the following join statement but it doesn't seem to work for any row with a . in it. dbo.TableA

How to join two table with partial match

爷,独闯天下 提交于 2020-01-15 23:04:12
问题 I have two table with the following data: TableA.name R4.23-Core-2 R4.23-Core-2 LA#213 CGHPBXsw01 127.213 0024-737e-e341 LA#252 CGHRack1sw01 127.252 0022-57ab-d781 SOC-01A-SW01 to - R4-DISTR-9512 to-R2-DISTR-5900-1 to-R3.25-EDGE TableB.caption R4.23-Core-2.ehd.ca R4.23-Core-2.nhd.ca CGHPBXsw01 CGHRack1sw01 SOC-01A-SW01 R4-DISTR-9512 R2-DISTR-5900-1.phsnc. R3.25-EDGE.phsne.edjc.ca I've tried using the following join statement but it doesn't seem to work for any row with a . in it. dbo.TableA

How add 0 in front of every single digit of a string?

最后都变了- 提交于 2020-01-15 20:10:34
问题 Given a string such as September 3 September 3 September 2 September 1 September 10 August 14 I want to have an output of September 03 September 03 September 02 September 01 September 10 August 14 Tried some regular expressions with no luck :/ 回答1: use this simple pattern \b(\d)\b and replace w/ 0$1 Demo # \b(\d)\b \b # <word boundary> ( # Capturing Group (1) \d # <digit 0-9> ) # End of Capturing Group (1) \b # <word boundary> 回答2: You could try finding only numbers which are single digit

How add 0 in front of every single digit of a string?

帅比萌擦擦* 提交于 2020-01-15 20:10:27
问题 Given a string such as September 3 September 3 September 2 September 1 September 10 August 14 I want to have an output of September 03 September 03 September 02 September 01 September 10 August 14 Tried some regular expressions with no luck :/ 回答1: use this simple pattern \b(\d)\b and replace w/ 0$1 Demo # \b(\d)\b \b # <word boundary> ( # Capturing Group (1) \d # <digit 0-9> ) # End of Capturing Group (1) \b # <word boundary> 回答2: You could try finding only numbers which are single digit

replace text without function

放肆的年华 提交于 2020-01-15 12:48:08
问题 I've a php question. I've a php code, it prints some long texts. I want replace "n" character in output text with "N". I can create a function. but I can't (and don't like!) put my text to a function (because I have many texts!). Is there any way to replace "n" with "N" without any function??? Thanks .. 回答1: No need to create a function, just use str_replace, the built in function for this purpose like this: $output_text = str_replace('n', 'N', $input_text); echo $output_text; [EDIT] If you

Find and Replace a section of a string with wildcard type search

岁酱吖の 提交于 2020-01-15 12:47:09
问题 I want to be able to read a file, and replace all instances of: M9S1800.2 with S1800 (I want to get rid of the M9 and the .2). The problem I am having is that the 4 digit number after the "S" can be different every time, as well as the number after the decimal. For example, It can be: M9S3200.1 or M9S5400.1 or M9S5400.2 Can someone please show me how to do this with C#? I know how to find and replace by using this code: StreamReader reader = new StreamReader(fDialog.FileName.ToString());

C Replace one character in an char array by another

感情迁移 提交于 2020-01-15 09:56:48
问题 I have the following C Code #include <stdio.h> int main(void){ char c[] = "ABC" printf("%s ", c); c[1] = 'B'; printf("%s", c); return 0; } The output I want is ABC BBC but the output I get is ABC ABC . How can I replace the first character in an String / char array? 回答1: Indexing in C arrays start from 0 . So you have to replace c[1] = 'B' with c[0] = 'B' . Also, see similar question from today: Smiles in output C++ - I've put a more detailed description there :) 回答2: below is a code that