Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
私はsplice2つのことをテストするようなものを取り入れようとしています:
splice
どうすればこれを行うことができますか?つまり、たとえば
var string = 'Special Place Co. (123 ABC)'
したがって、これは返されます
'Special Place Co' [見つかった '.' スプライス後に削除]
ありがとう
これがあなたのために働くコードです:
var string = 'Special Place Co. (123 ABC)'; if (string.length > 20) { string = string.substr(0,20); } string = string.replace(/([a-zA-Z0-9 ]+)(.*)/,'{$1}'); console.log(string);
http://jsfiddle.net/U5ZtU/