formatting

using regex to validate input formatting in C#

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-11 02:25:49
问题 This is a super basic question (I am brain dead today): How do I validate in input using regexes, to see: 1) if the input is in a certain form 2) if the input is all caps (just casting the input to caps is not feasible for this) I want ot make sure my inputs are in the form XX_XX. Here isi what I have: public bool IsKosher(string input) { Regex r = new Regex(input); if(r.Matches([A-Z]_[A-Z])) { return true; } return false; } Any ideas why it's not compiling? Thank you! 回答1: You are missing

Format cell as minutes : seconds in google spreadsheets

南楼画角 提交于 2019-12-11 02:24:12
问题 I wish to record data on the amount of time it takes for me complete a certain programming problem. I am using google spreadsheets to maintain my performance. The issue am facing is that, I want the cells to accept the result as mm:ss , but google sheet is converting it to 12-hr format i.e. hh:mm:ss , how can I stop this from happening? For Eg :- 1:30 gets converted to 1:30:00 AM . 回答1: Update: I found a new way to do it that actually does give you the value you want: =TEXT(TIME(,text(A1,"HH"

How to write array to Excel with differing styles per column using Axlsx

a 夏天 提交于 2019-12-11 02:22:39
问题 I would like to be able to use the Axlsx gem to write out an Excel spreadsheet with different styles applied to different columns. I am writing an Array of Hashes an entire row at a time and, as a result, I cannot seem to format the columns differently as needed. I don't know how to say, "for columns A-D use default styling, however for column E and F, use horizontal center alignment". require 'axlsx' p = Axlsx::Package.new wb = p.workbook # Default Style for all cells standard_text = wb

PHP transforming time formats and adding random time vars

对着背影说爱祢 提交于 2019-12-11 02:21:55
问题 I need to generate a time of format : [ Y-m-d H:i:s ] from strings that look like 7/03/2013 ( yep, can be 7 or 07 ) . I use $date = '7/03/2013'; $date = date('Y-m-d H:i:s', strtotime($date)); This works just fine . So where is the problem ? The problem is that I do not have the H:i:s part, but I need it in order to insert to DB. So I just tried to random it : $rand = rand(00,24); $datenew = date('Y-m-d '.$rand.':i:s', strtotime($date)); but that produces time like 4 or 6 where i need 04 and

adding zeros in objective-c string formats

余生长醉 提交于 2019-12-11 02:06:08
问题 Quick question: I am trying to fill in empty spaces with a specific number of zeroes in an NSString stringWithFormat formatting string. For example, I want: @"The number is %d", 5 // I want this to output 'the number is 05' @"the number is %d", 10 // I want this to output 'the number is 10' I know how to do this in Java, but I cant seem to find the same function in objective-c. Any help would be great. 回答1: If in Java you use System.out.printf() , then it's the same format syntax in Objective

Format inline output conditional on textual context

别来无恙 提交于 2019-12-11 02:04:13
问题 Using a modification (adapted from Jason French's blog post here) to the default inline knitr hook, I am printing numeric output rounded to 3 decimal places. If the value is less than 0.001, it returns "< 0.001". Here's an MWE showing the hook modification, and how I might use it in practice in R Markdown: ```{r setup, echo=FALSE} library(knitr) inline_hook <- function(x) { if (is.numeric(x)) { res <- ifelse(x == round(x), sprintf("%d", x), sprintf("%.3f", x) ) res <- ifelse(x < 0.001, '< 0

What is the right way to format Time between different timezones?

◇◆丶佛笑我妖孽 提交于 2019-12-11 01:58:42
问题 I want to format time like 19:19:00 to different time zones. If I use SimpleDateFormat it always takes into account the start of the epoch: 1970.01.01. Some timezones have different offsets on the start of the epoch and now. For example, the default offset from Europe/Kiev now is UTC+0200 but in 1970 it was UTC+0300. That means if I run my server under Europe/Kiev the client which login under Europe/Berlin(UTC+0100) will see three hours different instead of two. I can solve this problem by

SCHEME recursion perfect number (beginner, hopefully easy fix)

北城余情 提交于 2019-12-11 01:49:04
问题 having an issue with my perfect number function. The objective of the code is to determine if the number is a perfect number, meaning it is equal to the sum of its divisors. Ex:6. Im having trouble with my code. Here's my function: (define (is-perfect x) (define (divides a b) (= (modulo b a) 0)) (define (sum-proper-divisors y) (if (= y 1) 1 (if (divides y x) (+ y (sum-proper-divisors (- y 1))) (if (= x 1) #f (= (sum-proper-divisors (- x 1) x))))))) 回答1: You almost got it! there are a couple

Multiplication table with rows and columns

China☆狼群 提交于 2019-12-11 01:48:29
问题 How can I make multiplication table to look like this: http://i.imgur.com/rR6JSua.png ? With my code it only has one column. #include<stdio.h> int main() { int i, j; for(i = 1;i <= 9;i++) { for(j = 1;j <= 9;j++) { printf("%d * %d = %d\n",i , j,i*j); } printf("%d * %d = %d\n",i , 10,i*10); printf("\n"); } return 0; } 回答1: Try This: #include<stdio.h> int main() { int i, j; for(i = 1;i <= 9;i+=3) { for(j = 1;j <= 10;j++) { printf("%2d * %2d = %2d ",i , j,(i)*j); printf("%2d * %2d = %2d ",i+1 , j

Trigger Eclipse's code formatter programmatically from a new file wizard

谁说我不能喝 提交于 2019-12-11 01:35:52
问题 I'm writing an Eclipse plugin with a wizard ( org.eclipse.jface.wizard.Wizard ) which creates a new file with a basic code template. To simplify the "piecing together" of the file contents, I plan to stuff everything into one long string, inject it into the file, and then call my custom Formatter (inherits org.eclipse.xtext.formatting.impl.AbstractDeclarativeFormatter ) to clean up all the indentation and so on. Question is, how do I go about calling the formatter programmatically? In the