truncate

Split string data on a string match

感情迁移 提交于 2019-12-08 07:35:46
问题 I'm working with some xml and I'd like to clean it up before I parse it. What i'd like to do specifically, is take the data (example below) and match it on the string " <data> " and then trim everything before it leaving the node in tact. Then I would match on the string " </data> " and truncate everything after it, once again leaving the matched node in tact. Turning this: <dwml> <head> <child></child> </head> <data> <child></child> <child></child> </data> <more></more> </dwml> into this:

Average aggregation temporal database 10-minute interval in PostgreSQL

浪尽此生 提交于 2019-12-08 05:54:00
问题 I have a time series data where I want to perform aggregation on it by average function. Aggregation should be performed in 10-minute intervals: (HH-1):50, HH:00, HH:10, HH:20, HH:30, HH:40 or alternatively in 10-minute intervals: (HH-1):51, HH:01, HH:11, HH:21, HH:31, HH:41. Note: hourly mean of 5 o'clock is average of (4):51, 5:01,5:11, 5:21, 5:31, 5:41 values. The problem is that a data-set includes the variables with odd and even frequencies in time. So, I cannot assign an aggregation for

html value is truncating my string

心不动则不痛 提交于 2019-12-08 02:03:48
问题 On my page I am using HTML5 to upload a file on my browser. The file is a PDF an have to show it in a <input type="text"/> This is my code: var files = evt.target.files; // FileList object // files is a FileList of File objects. List some properties. for (var i = 0, f; f = files[i]; i++) { console.log(f.name); console.log(f.type); console.log(f.size); //Update document info $("#document_filename").find("input").val(f.name); $("#document_mimetype").find("input").val(f.type); var reader = new

Truncate model property in ASP.Net MVC

霸气de小男生 提交于 2019-12-07 23:08:20
问题 Im currently using a truncate and texteditor in different way. And both is working fine but I facing this problem. I want to truncate a text inside the texteditor. T_T Im using truncate this way and its working @helper Truncate(string input, int length) { if (input.Length <= length) { @input } else { @input.Substring(0, length)<text>...</text> } } @foreach (var item in Model) { <div> @Truncate(item.DetailDescription, 400) </div> } AND Im declaring raw to call a texteditor this way and its

php extracting first image from html string, remove all images tag, and truncate html string

心已入冬 提交于 2019-12-07 21:05:56
问题 I save in database an html content from tinymce editor, so I would want display this html content on php page, but in beautiful way. I would want first check if in html string is present an image, if it is present then display it first in php page. Then I would want display some text on right of image, truncating it first 200 words, but it must maintain html because it is possible that are present also links not only simple text. Is there a php library or php class for manipulating html and

C Delete last n characters from file

心不动则不痛 提交于 2019-12-07 02:11:46
问题 I need to delete the last n characters from a file using C code. At fist I was trying to use '\b', but it returns a Segmentation Fault. I have seen interesting answers to similar questions here and here, but I would prefer to use mmap function to do this, if it's possible. I know it could be simpler to truncate the file by creating a temp file, and writing chars to temp until some offset of the original file. The problem is I don't seem to understand how to use mmap function to do this, can't

Split string data on a string match

安稳与你 提交于 2019-12-06 20:37:28
I'm working with some xml and I'd like to clean it up before I parse it. What i'd like to do specifically, is take the data (example below) and match it on the string " <data> " and then trim everything before it leaving the node in tact. Then I would match on the string " </data> " and truncate everything after it, once again leaving the matched node in tact. Turning this: <dwml> <head> <child></child> </head> <data> <child></child> <child></child> </data> <more></more> </dwml> into this: <data> <child></child> <child></child> </data> My Question: While I am sure there is a way to do this, I

How to make a Multi-line (2 lines) label truncate the last line (OS X)

本秂侑毒 提交于 2019-12-06 13:52:22
I'm trying to make a multi-line label with 2 lines truncate the last line only. But it seems that, if I choose the Layout of that label as Truncates , my multi-line label becomes one-line. Here's what I want (I manually typed "..." for demonstration purposes): Here's what I have when I set my label as Truncates in IB (as you can see it still has 2 lines but acts as if it was only 1): Is this supposed to happen? If not, how can I achieve the truncate style of the first image? Thanks! It looks as though you must have Uses Single Line Mode checked, which should be unchecked. Also, under Layout is

Truncate model property in ASP.Net MVC

非 Y 不嫁゛ 提交于 2019-12-06 13:30:58
Im currently using a truncate and texteditor in different way. And both is working fine but I facing this problem. I want to truncate a text inside the texteditor. T_T Im using truncate this way and its working @helper Truncate(string input, int length) { if (input.Length <= length) { @input } else { @input.Substring(0, length)<text>...</text> } } @foreach (var item in Model) { <div> @Truncate(item.DetailDescription, 400) </div> } AND Im declaring raw to call a texteditor this way and its also working fine @html.Raw(item.DetailDescription) PROBLEM: How could I possibly combine the two in a

Truncate a HTML formatted text with SMARTY

丶灬走出姿态 提交于 2019-12-06 04:06:01
I've got a variable which is formatted with random HTML code. I call it to {$text} and i truncate it. The value is for example: <div>Lorem <i>ipsum <b>dolor <span>sit </span>amet</b>, con</i> elit.</div> If i truncate the text's first ~30 letters, I'll get this: <div>Lorem <i>ipsum <b>dolor <span>sit The problem is, I can't close the elements. So, I need a script, which check the <*> elements in the code (where * could be anything), and if it dont have a close tag, close 'em. Please help me in this. Thanks. Solution after hours, and 4 vote-up @ stackoverflow: PHP: ... function closetags(