Get first letter of each word in a string, in JavaScript

后端 未结 17 1662
后悔当初
后悔当初 2020-12-05 04:00

How would you go around to collect the first letter of each word in a string, as in to receive an abbreviation?

Input: "Java Script Object

17条回答
  •  悲&欢浪女
    2020-12-05 04:39

    The regular expression versions for JavaScript is not compatible with Unicode on older than ECMAScript 6, so for those who want to support characters such as "å" will need to rely on non-regex versions of scripts.

    Event when on version 6, you need to indicate Unicode with \u.

    More details: https://mathiasbynens.be/notes/es6-unicode-regex

提交回复
热议问题