comma

Java: Regex not matching

家住魔仙堡 提交于 2019-12-11 02:49:51
问题 I have comma separated string values. Every string may contain characters or numbers along with '-' or '/' or '.'. My code looks like: final String VALUES_REGEX = "^\\{([0-9a-zA-Z\\-\\_\\.])+,*([0-9a-zA-Z\\-\\_\\.])*\\}$"; final Pattern REGEX_PATTERN = Pattern.compile(VALUES_REGEX); final String values = "{df1_apx.fhh.irtrs.d.rrr, ffd1-afp.farr.d.rrr.asgd}"; final Matcher matcher = REGEX_PATTERN.matcher(values); if (null != values && matcher.matches()) { // further logic } ... ... Here if

Lifetime of return value in comma separated statements

情到浓时终转凉″ 提交于 2019-12-11 01:19:47
问题 Is the order of execution of the three commented lines below guaranteed? struct S { S() { /* called 1st */ } ~S() { /* called 3rd */ } }; boost::shared_ptr<S> f() { return boost::shared_ptr<S>(new S); } int second() { return 0; /* called 2nd */ } int test() { return (f(), second()); } With my compiler, the shared_ptr returned by f() seems to persist until after second() is called. But is this guaranteed by the standard and thus other compilers? 回答1: Yes . Temporaries persist until the

Preloading images using PHP and jQuery - Comma separated array?

微笑、不失礼 提交于 2019-12-10 23:15:58
问题 So I'm building a website that will use a lot of animated GIF's on mouse hover. There will be a lot of images, and I only want to load the images that will be used on any given page. It's using WordPress so I can use the conditional tags to only put out the URL's of the images I need on a certain page. My problem was how to tell the browser/server which images needed to be preloaded. I decided to add a HTML5 data attribute to the containing element. For example, I would have a DIV with this

split comma-separated column entry into rows

怎甘沉沦 提交于 2019-12-10 21:27:06
问题 I have already found other versions of the same question but I was not able to adapt the answers given there for my problem. Here is an older link: The op there had data consisting of two columns only - and the given answer handles this really nicely. But what about more than two columns? Is there a way to adapt the linked code snippet? Here is an example: ve <- rbind("4,2","3","1,2,3","5","6","7") expl <- cbind(head(mtcars),ve) row.names mpg cyl disp hp drat wt qsec vs am gear carb ve 1

Why can't compilers expand arguments of a variadic template via comma operator?

China☆狼群 提交于 2019-12-10 15:31:56
问题 I know that we can't use variadic expansions as if it is a chain of comma operators. In that question the sample is like this: template<typename... Args> inline void increment_all(Args&... args) { ++args...; } It might be ambiguous either to increment or expand first so parentheses won't hurt: template<typename... Args> inline void increment_all(Args&... args) { (++args)...; } or something like this: template<typename... Args> void cout_all(Args&&... args) { (std::cout << std::forward<Args>

Comma usage in swift

北战南征 提交于 2019-12-10 14:43:20
问题 @IBAction func selectedGame(segue:UIStoryboardSegue) { if let gamePickerViewController = segue.sourceViewController as? GamePickerViewController, selectedGame = gamePickerViewController.selectedGame { detailLabel.text = selectedGame game = selectedGame } } Hi all, i'm following a tutorial to learn something about swift. Yesterday I found this part of code but I can not find a way to understand what it means thatcomma means. Can u pls explain me? 回答1: The comma is used to combine multiple

Java: what's the difference between the sv and sv_SE locale?

社会主义新天地 提交于 2019-12-10 13:22:44
问题 I tried to parse a string (-0,3) to a double in java using Swedish locale using this code: String DoubleString = "-0,3" NumberFormat swedishNumberFormat = NumberFormat.getInstance(new Locale("sv")); System.out.println(swedishNumberFormat.parse(doubleString).doubleValue()); When I tried with the sv_SE locale the result was -3.0, which, obviously, is incorrect. I then, after a lot of headache changed the locale to sv (as in the example above) and then the result was correct, -0,3. According to

Java Regex - split comma separated list, but exclude commas within parentheses

左心房为你撑大大i 提交于 2019-12-10 10:12:12
问题 I'm trying to write regex that will split a Java string like this: 300x250,468x60,300x400v(480x320,768x1024,100x100),400x300v,640x480v(200x200,728x90) in to something like this: 300x250 468x60 300x400v(480x320,768x1024,100x100) 400x300v 640x480v(200x200,728x90) I've been trying \,(\()? but this ends up selecting the commas in the parentheses as well. Any help appreciated! 回答1: If you have to use regex you can split on ,(?![^(]*\\)) If not then one simple iteration over characters can do the

How do I get the maximum value in a comma separated field in MySQL?

时光怂恿深爱的人放手 提交于 2019-12-08 11:28:23
问题 I have a MySQL table that has a field of comma separated values. How do I get the maximum value? Example: CREATE TABLE `test`.`scale` (`scale` VARCHAR(500)); INSERT INTO `test`.scale VALUES ('1,5,0.3,0.8,1'), ('0.5,0.7,0.1,0.3'), ('7,0.5,0.7,4'); scale: 1,5,0.3,0.8,1 0.5,0.7,0.1,0.3 7,0.5,0.7,4 answer: 5 0.7 7 How do I select the max value in this string? Unfortunately I can't change the way the previous person implemented the comma separated solution. I hope there is a MySQL function that

T-SQL — convert comma-delimited column into multiple columns

心已入冬 提交于 2019-12-08 02:07:35
问题 From the table below, how can I convert the Values column into multiple columns, populated with individual values that are currently separated by commas? Before the conversion: Name Values ---- ------ John val,val2,val3 Peter val5,val7,val9,val14 Lesli val8,val34,val36,val65,val71,val Amy val3,val5,val99 The result of the conversion should look like: Name Col1 Col2 Col3 Col4 Col5 Col6 ---- ---- ---- ---- ---- ---- ---- John val val2 val3 Peter val5 val7 val9 val14 Lesli val8 val34 val36 val65