text-manipulation

How to format plaintext like a book/magazine with PHP?

人走茶凉 提交于 2020-01-22 02:48:09
问题 This question was migrated from Super User because it can be answered on Stack Overflow. Migrated 9 days ago . I have: This is a test string. Cool, huh? I want: This is a te- st string. C- ool, huh? That is, each line is exactly 13 chars, according to the English rules for this . That is, I'm not sure if "test" can be broken up like "te-st", or that "Cool" can be broken up to "C-ool", but that's the "style" I'm trying to achieve. I've made about a thousand search queries. I find nothing

Convert numbers to words with VBA

99封情书 提交于 2019-12-31 02:32:08
问题 I have a column of numbers. In the next column, I want the text/word conversion of the numbers. Example : 123.561 would convert to One hundred twenty three point five six one . I do not want to convert to currency, just number to text, with any number of decimal places. How can I do this? 回答1: Edit: I've adapted the procedure below to non-currency, unlimited decimal places. Edit 2 considers internationalisation via two changes in (1) Function SpellNumber and (2) Function fractionWords to make

Edit configuration file through python

馋奶兔 提交于 2019-12-22 04:42:57
问题 I need to edit a configuration file through python and i tried searching on stackoverflow and google and they don't cover my situation, since i need to replace lines in the file and perform matches in my search. Also, what i found covers how to do it for one line, i will be performing at least 8 line replacements in the file and I would like to know if there is a cleaner and more elegant way of doing this than putting 10 replace(foo, bar) lines altogether. I need to "match" lines like

Find url in plain text and insert HTML A markups

此生再无相见时 提交于 2019-12-19 04:15:26
问题 I have text with URL and I need to wrap them with HTML A markup, how to do that in c#? Example, I have My text and url http://www.google.com The end. I would like to get My text and url <a href="http://www.google.com">http://www.google.com</a> The end. 回答1: You can use a regex for this. If you need a better Regex you can search for it here http://regexlib.com/Search.aspx?k=url My quick solution for this would be this: string mystring = "My text and url http://www.google.com The end."; Regex

How to get Git log with short stat in one line?

☆樱花仙子☆ 提交于 2019-12-18 12:47:57
问题 Following command outputs following lines of text on console git log --pretty=format:"%h;%ai;%s" --shortstat ed6e0ab;2014-01-07 16:32:39 +0530;Foo 3 files changed, 14 insertions(+), 13 deletions(-) cdfbb10;2014-01-07 14:59:48 +0530;Bar 1 file changed, 21 insertions(+) 5fde3e1;2014-01-06 17:26:40 +0530;Merge Baz 772b277;2014-01-06 17:09:42 +0530;Qux 7 files changed, 72 insertions(+), 7 deletions(-) I'm interested in having above format to be displayed like this ed6e0ab;2014-01-07 16:32:39

Extracting strings from binary file using regex and converting to ASCII — Using Perl

你。 提交于 2019-12-13 19:37:13
问题 Trying to figure out how to extract a string off characters from a binary file and convert them to ascii. The characters are a barcode, which is preceded by a constant string of text. My thought is to figure out what the HEX pattern is for the string constant string and extract the string based on that, then convert the HEX to ASCII. Problem is I don't know how get perl to "read" the file, or "see" what it's seeing. Meaning that if the file was a text file, might do something like this - Perl

Excel parsing and converting text

时光毁灭记忆、已成空白 提交于 2019-12-11 12:38:30
问题 I need to be able to convert cells from one format to another according to the following rules: Property Description --enter as-- Folio Identifier ---------------------------------------------------------- Lot 23 DP789678 23/789678 Lot 7 Section 12 DP6789 7/12/6789 Lot 1 SP 45676 1/SP45676 Common Property Title SP45676 CP/SP45676 Volume 7456 Folio 56 7456-56 Auto-Consol 5674-78 5674-78 Water Access Licence No. 123 WAL123 So the thing on the left has to be changed to the item on the right. For

How to convert text file automatically to graphviz dot file?

天大地大妈咪最大 提交于 2019-12-10 23:43:41
问题 I am trying to convert my text file to an undirected graph automatically with the help of graphviz. The text file consists of the following code: 0 A Relation B A Relation C B Relation C 1 0 A Relation C B Relation C 1 Here A, B and C are nodes. I may require a single or multiple graphs. 0 and 1 represent the start and end of each graph. The number of relations may also vary. I tried to proceed with sed, but got lost. How should I proceed to get the graph I require? Thanks for your help. 回答1:

Transforming a sentence creates an infinite loop - but how?

折月煮酒 提交于 2019-12-10 18:09:31
问题 I can't figure out where this is going wrong. Please note that I am very new to Prolog and I'm sure I'm missing something - just no idea what that might be. Could anyone help me out please? Thanks, here is my code: printSentence([]). printSentence([W|[]]) :- write(W), write('.'), nl. printSentence([W|R]) :- write(W), write(' '), printSentence(R). transform([], Result). transform([Word|Rest], Result) :- replace(Word, Replacement), append(Result, Replacement, NewResult), transform(Rest,

Extracting “plaintext” header from HEX file using Perl

こ雲淡風輕ζ 提交于 2019-12-08 13:09:25
问题 Have a file that appears to have plaintext headers in them that I would like to extract and convert to plaintext. Using HEXedit, this is what I'm seeing, which is in a file: 3a40 - 31 65 33 38 00 00 00 00 00 00 00 00 00 00 00 00 - 1e38............ 3a50 - 00 00 00 00 00 00 00 00 00 00 0a 00 74 00 65 00 - ............t.e. 3a60 - 78 00 74 00 2f 00 61 00 73 00 63 00 69 00 69 00 - x.t./.a.s.c.i.i. 3a70 - 00 00 18 00 61 00 66 00 66 00 79 00 6d 00 65 00 - ....a.f.f.y.m.e 3a80 - 74 00 72 00 69 00 78