string-formatting

Setting parts of a String to Bold in UIView

前提是你 提交于 2019-12-08 10:47:18
问题 I'm parsing an XML file an get a string as NSMutableString . Now I want to show this string as text in my UIView . So, I created a TextView and set its value to my string. The result was that I have the text with HTML Tags shown up in the TextView. There is no problem removing the tags from the string, but some of the text needs to appear as bold. Is there any way to display parts of a string as bold programmatically? I replaced <br> Elements with \n and it works fine for line-break. But I

Function to parse date to parts

邮差的信 提交于 2019-12-08 09:12:10
问题 Is there any nice function in PHP to parse the date into parts given the specified format? e.g. some_function('20112000', 'dmY') some_function('2000-11-20', 'Y-m-d') some_function('2000 text 11-20', 'Y text m-d') array('d'=>20, 'm'=>11, 'Y'=>2000) expected in all of the above cases, (assuming formats compatible with date() function) Update: I use PHP 5.1.9 This is also possible using Zend_Date , but it uses different formats than date() (e.g. ddMMyyyy ) 回答1: With PHP >= 5.3, the DateTime:

String formatting in scala

拟墨画扇 提交于 2019-12-08 09:03:20
问题 I am looking for a string format solution in Scala. I have the below string: str = {"card_id" : %s,"cust_id": %s,"card_info": {"card_type" : "%s","credit_limit": %s},"card_dates" : [{"date":"%s" },{"date":"%s" }]} And here I want to replace "%S" with string value. Is there any function in Scala so that I can apply that function and get the proper result? I have tried string.format("%s", str, arrayofvalue) but it's not giving the proper result. 回答1: In scala you can do this val i = 123 val s =

Java printff string only output formatting

不羁的心 提交于 2019-12-08 09:01:37
问题 How do I format output by using printf. suppose i want to print following in formatter. testing testing testing testing testingggg testingggg testingggg testingggg I am not asking about using "\t", I am asking on printf style formatting? If some one can give me suggestion and example. Or may be link with example. I can do it to fit my need. 回答1: I think you're looking for the Formatter class, which does printf-style formatting for Java. For example, applied to your input: StringBuilder sb =

Format as currency with no trailing zeroes in wpf xaml

非 Y 不嫁゛ 提交于 2019-12-08 06:54:26
Assuming we have a viewmodel property MyMoney . How can I format it in its view xaml as a currency with no trailing zeroes? For example: MyMoney = 1; //$1 MyMoney = 1.2 //$1.2 I've tried the following in xaml (e.g. <TextBox Text="{Binding MyMoney, StringFormat=..."/> ) but it doesn't satisfy all the conditions: StringFormat=C shows currency but also trailing zeroes. StringFormat=C0 shows currency but shows only the whole number. StringFormat={}{0:0.##} does not show trailing zeroes but not as currency. StringFormat={}{0:$0.##} does not show trailing zeroes but hard-coded $ . We should be able

Format as currency with no trailing zeroes in wpf xaml

做~自己de王妃 提交于 2019-12-08 04:03:44
问题 Assuming we have a viewmodel property MyMoney . How can I format it in its view xaml as a currency with no trailing zeroes? For example: MyMoney = 1; //$1 MyMoney = 1.2 //$1.2 I've tried the following in xaml (e.g. <TextBox Text="{Binding MyMoney, StringFormat=..."/> ) but it doesn't satisfy all the conditions: StringFormat=C shows currency but also trailing zeroes. StringFormat=C0 shows currency but shows only the whole number. StringFormat={}{0:0.##} does not show trailing zeroes but not as

Binding a unit label in WPF textbox

[亡魂溺海] 提交于 2019-12-08 02:32:29
问题 I'm binding a pressure to a textbox. The pressure could be in PSI, KPA, BARS, etc. I would like to display the unit inside the textbox next to the value. There doesn't seem to be a way to bind the Units string property in my viewmodel to the StringFormat option of the value binding. Is there any way to accomplish this without retemplating the textbox? 回答1: You can use MultiBinding : <TextBox> <TextBox.Text> <MultiBinding StringFormat="{}{0} {1}"> <Binding Path="Pressure" /> <Binding Path=

Format a hexadecimal sequence in a cmd.exe batch file

戏子无情 提交于 2019-12-08 02:29:34
问题 In a Windows cmd script (aka bat script), I have a FOR /L loop from 1 to 8, where I need to do a bit shift and somehow format a variable as a hexadecimal number (which if you ask, is a single CPU identifier bit to feed into /AFFINITY). I can't figure out how to do the last step. This is my loop.cmd file: @ECHO OFF SETLOCAL ENABLEDELAYEDEXPANSION FOR /L %%i IN (1,1,8) DO ( SET /A "J=1<<%%i" ECHO %%i and !J! ) which does everything but format a hex number: 1 and 2 2 and 4 3 and 8 4 and 16 5 and

Currency Culture Formatting not applying on DataGridView Column

风流意气都作罢 提交于 2019-12-08 02:27:19
问题 I have 2 DataGridViews (DGV), and in both I have currency columns which I want to format. The code I'm writing seems to work in one, but not in the other. Both the DGV's are set up this way: Data is first loaded into a DataTable. A BindingSource then links to this DataTable. And lastly the DGV's use this BindingSource object for their data. I use the following code in the form's Load event to customize both DGVs' currency columns: dataGridView.Columns[columnIndexHere].DefaultCellStyle

How do you format text/strings in VBA?

纵然是瞬间 提交于 2019-12-08 01:06:44
问题 In the code below, I take some input parameters, either text or a cell, and combine them to form one string using the formatting I need. I need to make Task_Name bold, as well as text like "Lead :". I know you cannot make text in a variable bold, but how do I go about this? This cell I'm storing the value in is eventually used in a Word mail merge. I need to format part of a string. In the code below, I need to make Task_Name, "Lead : ", etc. all bold. Function GENERATE_STAFFING_SECTION(Task