How to split a string, but also keep the delimiters?

How to split a string, but also keep the delimiters?

I have a multiline string which is delimited by a set of different delimiters:(Text1)(DelimiterA)(Text2)(DelimiterC)(Text3)(DelimiterB)(Text4)I can split this string into its parts, using String.split, but it seems that I can't get the actu

How to send an object from one Android Activity to another using Intents?

How to send an object from one Android Activity to another using Intents?

How can I pass an object of a custom type from one Activity to another using the putExtra() method of the class Intent? 1:If you're just passing objects around then Parcelable was designed for this. It requires a little more effort to us

What's the difference between JavaScript and Java?

What's the difference between JavaScript and Java?

What's the difference between JavaScript and Java? 1:Java and Javascript are similar like Car and Carpet are similar. 2:One is essentially a toy, designed for writing small pieces of code, and traditionally used and abused by inexperi

What uses are there for “placement new”?

What uses are there for “placement new”?

Has anyone here ever used C++'s "placement new"? If so, what for? It looks to me like it would only be useful on memory-mapped hardware. 1:Placement new allows you to construct an object on memory that's already allocated.You may want to

How to style a  dropdown with CSS only without JavaScript?

How to style a dropdown with CSS only without JavaScript?

Is there a CSS-only way to style a form as much as humanly possible, without any JavaScript. What are the properties I can use to do so in CSS?This code needs to be compatible with all major brow

Prototypical inheritance - writing up [duplicate]

Prototypical inheritance - writing up [duplicate]

This question already has an answer here: Javascript object members that are prototyped as arrays become shared by all class instances 3 answers So I h

PHP parse/syntax errors; and how to solve them?

PHP parse/syntax errors; and how to solve them?

Everyone runs into syntax errors. Even experienced programmers make typos. For newcomers it's just part of the learning process. However, it's often easy to interpret error messages such as: PHP Parse error: syntax error, unexpected '{' in

How do you access the $on, $emit, $broadcast methods with Controller as syntax?

How do you access the $on, $emit, $broadcast methods with Controller as syntax?

Using $scope it's easy to emit an event or watch for one.(function() { "use strict"; angular .module("app") .controller("Ctrl", [ "$scope", CtrlDefinition ]); function CtrlDefinition($scop

What's the R equivalent of SQL's LIKE 'description%' statement?

What's the R equivalent of SQL's LIKE 'description%' statement?

Not sure how else to ask this but, I want to search for a term within several string elements. Here's what my code looks like (but wrong):inplay = vector(length=nrow(des))for (ii in 1:nrow(des)) { if (des[ii] = 'In play%') inplay[ii] = 1 e

Persisting SCSS variables in rails asset pipeline?

Persisting SCSS variables in rails asset pipeline?

I'm upgrading a rails app with lots of SCSS stylesheets to use the asset pipeline, and need to include some global variables and mixins for each file.Adding several @import directives at the top of every file isn't very DRY, so I'd like to

Creating tuples from two vectors

Creating tuples from two vectors

If I have two vectors of the same length A and B how can I easily turn these two vectors into a single tuple vector i. e. c((5,7),(7,13))? 1:Others have mentioned lists. I see other possibilities:cbind(A, B) # makes a column-major 2x2-

Multiple left joins on multiple tables in one query

Multiple left joins on multiple tables in one query

I've got one master table, which has items stored in multiple levels, parents and childs, and there is a second table which may or may not have additional data. I need to query two levels from my master table and have a left join on my seco

Why I'm getting unexpected EOF for my cron job?

Why I'm getting unexpected EOF for my cron job?

I am receiving an error with my Cron job. The error I keep getting is: /bin/sh: -c: line 0: unexpected EOF while looking for matching `''/bin/sh: -c: line 1: syntax error: unexpected end of fileHere is my code:mysqldump -u database_user -p'

In the C++ standard, what is specified to occur when a “shall” requirement is violated?

In the C++ standard, what is specified to occur when a “shall” requirement is violated?

For example, the famous words (§3.2/1) No translation unit shall contain more than one definition of any variable, function, class type, enumeration type, or template.I believe "shall" requirements are to be interpreted as though they ar

C#: Any benefit of List.ForEach(…) over plain foreach loop?

C#: Any benefit of List.ForEach(…) over plain foreach loop?

I'm wondering why List.ForEach(Action) exists.Is there any benefit/difference in doing :elements.ForEach(delegate(Element element){ element.DoSomething(); });overforeach(Element element in elements) { element.DoSomething();}? 1:One key d

How to Java String.format with a variable precision?

How to Java String.format with a variable precision?

I'd like to vary the precision of a double representation in a string I'm formatting based on user input. Right now I'm trying something like:String foo = String.format("%.*f\n", precision, my_double);however I receive a java.util.UnknownFo

Embedding JSON Data into YAML file

Embedding JSON Data into YAML file

I am writing a fixture for my table. And a one of the coloums takes in a JSON string as a value.The problem is the fixture is not loading failing as:Fixture::FormatError: a YAML error occurred parsing /home/saurajeet/code/dcbox/test/fixture

Mysql: latin1-> utf8. Convert characters to their multibyte equivalents

Mysql: latin1-> utf8. Convert characters to their multibyte equivalents

There was a table in latin1 and site in cp1252 I want to have table in utf8 and site in utf-8I've done:1) on web page: Content-Type: text/html;charset=utf-82) Mysql: ALTER TABLE XXX CONVERT TO CHARACTER SET utf8_This SQL doesn't work as I w

Syntax for INSERTing into a table with no values?

Syntax for INSERTing into a table with no values?

I have a table created with the following schema:CREATE TABLE [dbo].[Visualizations]( VisualizationID int identity (1,1) NOT NULL)Since the table has no settable fields, I'm not sure how to insert a record. I tried:INSERT INTO [

SpriteKit: detect complete node overlap

SpriteKit: detect complete node overlap

I have two SKShapeNodes – one with an edge-based SKPhysicsBody, one volume-based – and I want to detect their intersection without collision. I've got this working fine, with the SKPhysicsContactDelegate contact methods getting called as on

Optional named arguments without wrapping them all in “OptionValue”

Optional named arguments without wrapping them all in “OptionValue”

Suppose I have a function with optional named arguments but I insist on referring to the arguments by their unadorned names.Consider this function that adds its two named arguments, a and b:Options[f] = {a->0, b->0}; (* The default values.

Define multiple methods with parameters from variadic templates

Define multiple methods with parameters from variadic templates

I want to define a base template class in a way so that it takes variadic template arguments and defines a virtual method for each argument, where the parameter is the argument type.E.g. Base should give me 3 virtual methods: Foo(int), Foo(

Creating stored procedure in another database

Creating stored procedure in another database

Any idea if it's possible to create a procedure in another database using T-SQL alone, where the name of the database is not known up front and has to be read from a table? Kind of like this example:Use [MasterDatabase]Declare @FirstDatabas

RSpec View testing: How to modify params?

RSpec View testing: How to modify params?

I am trying to test my views with RSpec. The particular view that is causing me troubles changes its appearance depending on a url parameter:link_to "sort>name", model_path(:sort_by => 'name') which results in http://mydomain/model?sort_by=

Scipy interpolation how to resize/resample 3x3 matrix to 5x5?

Scipy interpolation how to resize/resample 3x3 matrix to 5x5?

EDIT: Paul has solved this one below. Thanks!I'm trying to resample (upscale) a 3x3 matrix to 5x5, filling in the intermediate points with either interpolate.interp2d or interpolate.RectBivariateSpline (or whatever works).If there's a simpl