Build a Comma Delimited String

The laziest way is s = join(Application.WorksheetFunction.Transpose([a1:a400]), “,”) This works because .Value property of a multicell range returns a 2D array, and Join expects 1D array, and Transpose is trying to be too helpful, so when it detects a 2D array with just one column, it converts it to a 1D array. In production it … Read more

How to parse string to date in xslt 2.0

Like Tomalak said, you can use substring() and concat() to build a string you can cast as an xs:date() (It doesn’t sound like you want a dateTime.) Example: <xsl:stylesheet version=”2.0″ xmlns:xsl=”http://www.w3.org/1999/XSL/Transform” xmlns:xs=”http://www.w3.org/2001/XMLSchema”> <xsl:output method=”text”/> <xsl:strip-space elements=”*”/> <xsl:variable name=”in” select=”‘30042013′”/> <xsl:template match=”https://stackoverflow.com/”> <xsl:variable name=”date” select=”xs:date(concat( substring($in,5,4),’-‘, substring($in,3,2),’-‘, substring($in,1,2)))”/> <xsl:value-of select=”format-date($date,'[MNn] [D], [Y]’)”/> </xsl:template> </xsl:stylesheet> produces (with … Read more

Convert list in entity to single string column in database

If you use JPA 2.1, then you can create an AttributeConverter: @Converter public class StringListConverter implements AttributeConverter<List<String>, String> { @Override public String convertToDatabaseColumn(List<String> list) { // Java 8 return String.join(“,”, list); // Guava return Joiner.on(‘,’).join(list); } @Override public List<String> convertToEntityAttribute(String joined) { return new ArrayList<>(Arrays.asList(joined.split(“,”))); } } You can use this converter in your entity: … Read more

Replace substring of NSAttributedString with another NSAttributedString

Convert your attributed string into an instance of NSMutableAttributedString. The mutable attributed string has a mutableString property. According to the documentation: “The receiver tracks changes to this string and keeps its attribute mappings up to date.” So you can use the resulting mutable string to execute the replacement with replaceOccurrencesOfString:withString:options:range:.