format

Validate the format of a string of comma separated words with regex

僤鯓⒐⒋嵵緔 提交于 2020-03-14 05:41:28
问题 I'm trying to validate a string of comma separated words from a text field in a ruby class using regex. The following should be valid: word word, word, word word,word,word And the following should be invalid: word word word I thought this would work /([a-z]+){1}(,\s*[a-z]+)*/i On Rubular, it seems to be valid, but when I validate in my class as follows, it accepts what should be invalid strings. @tag_regex = /([a-z]+){1}(,\s*[a-z]+)*/i validates :tags, :allow_blank => true, :format => { :with

Validate the format of a string of comma separated words with regex

生来就可爱ヽ(ⅴ<●) 提交于 2020-03-14 05:40:04
问题 I'm trying to validate a string of comma separated words from a text field in a ruby class using regex. The following should be valid: word word, word, word word,word,word And the following should be invalid: word word word I thought this would work /([a-z]+){1}(,\s*[a-z]+)*/i On Rubular, it seems to be valid, but when I validate in my class as follows, it accepts what should be invalid strings. @tag_regex = /([a-z]+){1}(,\s*[a-z]+)*/i validates :tags, :allow_blank => true, :format => { :with

java日期格式大全 format SimpleDateFormat(留用)

若如初见. 提交于 2020-03-05 20:19:22
java日期格式大全 format SimpleDateFormat /** * 字符串转换为java.util.Date<br> * 支持格式为 yyyy.MM.dd G 'at' hh:mm:ss z 如 '2002-1-1 AD at 22:10:59 PSD'<br> * yy/MM/dd HH:mm:ss 如 '2002/1/1 17:55:00'<br> * yy/MM/dd HH:mm:ss pm 如 '2002/1/1 17:55:00 pm'<br> * yy-MM-dd HH:mm:ss 如 '2002-1-1 17:55:00' <br> * yy-MM-dd HH:mm:ss am 如 '2002-1-1 17:55:00 am' <br> * @param time String 字符串<br> * @return Date 日期<br> */ public static Date stringToDate(String time){ SimpleDateFormat formatter; int tempPos=time.indexOf("AD") ; time=time.trim() ; formatter = new SimpleDateFormat ("yyyy.MM.dd G 'at' hh:mm:ss z"); if(tempPos>-1){

monthCalender date format to yyyy-mm-dd : c#

梦想的初衷 提交于 2020-03-04 14:10:51
问题 I have a database in MySQL. Now i want to insert value for a attribute of type data in in the database which is of the format yyyy-mm-dd. I will be getting date from 'monthCalender'. Currently i am getting the date in format mm/dd/yyyy by using this code. monthCalendar1.SelectionStart.Date.ToShortDateString() How should i convert the format? also i feel its weird for MySQL to ask for such a format. So i may be wrong. by the way am using XAMPP for the database. 回答1: use this: monthCalendar1

PySpark: How to specify column with comma as decimal

核能气质少年 提交于 2020-02-28 03:05:14
问题 I am working with PySpark and loading a csv file. I have a column with numbers in European format, which means that comma replaces the dot and vice versa. For example: I have 2.416,67 instead of 2,416.67 . My data in .csv file looks like this - ID; Revenue 21; 2.645,45 23; 31.147,05 . . 55; 1.009,11 In pandas, such a file can easily be read by specifying decimal=',' and thousands='.' options inside pd.read_csv() to read European formats. Pandas code: import pandas as pd df=pd.read_csv(

PySpark: How to specify column with comma as decimal

自闭症网瘾萝莉.ら 提交于 2020-02-28 02:47:03
问题 I am working with PySpark and loading a csv file. I have a column with numbers in European format, which means that comma replaces the dot and vice versa. For example: I have 2.416,67 instead of 2,416.67 . My data in .csv file looks like this - ID; Revenue 21; 2.645,45 23; 31.147,05 . . 55; 1.009,11 In pandas, such a file can easily be read by specifying decimal=',' and thousands='.' options inside pd.read_csv() to read European formats. Pandas code: import pandas as pd df=pd.read_csv(

PySpark: How to specify column with comma as decimal

戏子无情 提交于 2020-02-28 02:46:07
问题 I am working with PySpark and loading a csv file. I have a column with numbers in European format, which means that comma replaces the dot and vice versa. For example: I have 2.416,67 instead of 2,416.67 . My data in .csv file looks like this - ID; Revenue 21; 2.645,45 23; 31.147,05 . . 55; 1.009,11 In pandas, such a file can easily be read by specifying decimal=',' and thousands='.' options inside pd.read_csv() to read European formats. Pandas code: import pandas as pd df=pd.read_csv(

Formatting Integers in JTable Column Cells With Commas

我的未来我决定 提交于 2020-02-16 03:03:54
问题 I have a Price column that displays integers in plain format like 1000000. I would like to know how can I format it with commas without affecting its value when retrieving with table.getValueAt()? Is there a method like table.setColumnCellFormat(decimalFormat)? 回答1: You need a custom TableCellRenderer which can format the value the way you need it. See Using Custom Renderers for more details import java.awt.BorderLayout; import java.awt.Component; import java.awt.EventQueue; import java.text

Oracle convert RAW to date format

混江龙づ霸主 提交于 2020-02-03 10:34:39
问题 I have a RAW field in my Oracle database that represents the date of user registered in system. The value is something like 24E2321A0000000000 However I need convert the value to the date it represents (etc 2008-12-25 15:04:31). I tried with totimestamp (see this sqlfiddle) but that didn't work. 回答1: Maybe this will help: SELECT utl_raw.cast_to_binary_integer('24E2321A0000000000') raw_to_int FROM dual / Output is 36. I'm not sure if you need days or hours. Next example is about adding 36

Is there a way to format text output in Ada

一个人想着一个人 提交于 2020-02-03 04:49:06
问题 Is there a way to format the string being outputted? I'm trying get a pretty view of the following output 1: Ashley | 01033438392 | Wellington, New Zealand | 1987- 4-14 2: Aloha | 01087651234 | Hawaii, United States of America | 1988- 9-23 3: Jack | 01082840184 | Beijing, China | 1989- 6-19 If I was programming in C, I would do something like printf("%10s | %11s | %20s | %4d-%2d-%2d\n",name,phone,address,year,month,day); Would it be possible to do this kind of formatting in Ada 05? PS Please