const theName = “Vincent van Gogh”; function hideWord(word) { if (word.length < 2) return word; return word.substring(0, 1) + ‘*’.repeat(word.length-1); } console.log(theName.split(” “).map(hideWord).join(” “)); OUTPUT: V****** v** G*** You could also wrap the whole lot in a function if you wanted to be able to call it from multiple places and avoid redefining it. function […]
Tag: word
How to wrap very long text in Asp.Net Razor
That will save you: <div style=”word-break: break-all;”> THEVERYVERYLOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOONGTEXT </div>
Get the First and Last Word from a String or Sentence in SQL
You can use the query below: DECLARE @Sentence VARCHAR(MAX) = ‘The quick brown fox jumps over the lazy dog’ DECLARE @first_space_index int = CHARINDEX(‘ ‘, @Sentence) – 1 DECLARE @last_space_index int = CHARINDEX(‘ ‘, REVERSE(@Sentence)) – 1 IF @first_space_index < 0 SELECT @Sentence AS [First Word], @Sentence AS [Last Word] ELSE SELECT SUBSTRING(@Sentence, 1, @first_space_index) […]
Capitalize words in SQL (Display data first letter uppercase rest lowercase)
SELECT UPPER(LEFT(colname,1)) + LOWER(RIGHT(colname, LEN(colname) – 1)) FROM tablename