Ensure String First Letter is Capitalised and Has a Full Stop At It's End


/ Published in: XSLT
Save to your folder(s)

Useful for handling badly formatted string. You could also use normalize-space to remove bad spaces if needed.


Copy this code and paste it in your HTML
  1. <!-- first char to uppercase-->
  2. <xsl:value-of select="concat( translate( substring( $my-string, 1, 1 ),$lowerCase, $upperCase ), substring( @type, 2, string-length( $my-string )))" />
  3. <!-- remainder of string -->
  4. <xsl:value-of select="substring($my-string,2,string-length($my-string)-1)" />
  5. <!-- fullstop -->
  6. <xsl:if test="substring($my-string,string-length($my-string)) !='.'">.</xsl:if>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.