-
charAt(pos: number): stringES1Returns the character at index
pos, as a string (JavaScript does not have a datatype for characters).str[i]is equivalent tostr.charAt(i)and more concise.> 'abc'.charAt(1) 'b' -
charCodeAt(pos: number): numberES1Returns the 16-bit number (0–65535) of the UTF-16 code unit (character) at index
pos.> 'abc'.charCodeAt(1) 98 -
codePointAt(pos: number): number | undefinedES6Returns the number of the Unicode code point of the 1–2 characters at index
pos. If there is no such index, it returnsundefined. -
concat(...strings: string[]): stringES3Returns the concatenation of
thisandstrings.'a'+'b'is equivalent to'a'.concat('b')and more concise.> 'ab'.concat('cd', 'ef', 'gh') 'abcdefgh' -
endsWith(searchString: string, endPos=this.length): booleanES6Returns
trueifthisends withsearchStringat indexendPosandfalse, otherwise.> 'foo.txt'.endsWith('.txt') true > 'abc'.endsWith('ab', 2) true -
includes(searchString: string, startPos=0): booleanES6Returns
trueifthiscontains thesearchStringandfalse, otherwise. The search starts atstartPos.> 'abc'.includes('b') true > 'abc'.includes('b', 2) false -
indexOf(searchString: string, minIndex=0): numberES1Returns the lowest index at which
searchStringappears withinthis, or-1, otherwise. Any returned index will beminIndexor higher.> 'abab'.indexOf('a') 0 > 'abab'.indexOf('a', 1) 2 > 'abab'.indexOf('c') -1 -
lastIndexOf(searchString: string, maxIndex=Infinity): numberES1Returns the highest index at which
searchStringappears withinthis, or-1, otherwise. Any returned index will bemaxIndexor lower.> 'abab'.lastIndexOf('ab', 2) 2 > 'abab'.lastIndexOf('ab', 1) 0 > 'abab'.lastIndexOf('ab') 2 -
match(regExp: string | RegExp): RegExpMatchArray | nullES3If
regExpis a regular expression with flag/gnot set then.match()returns the first match forregExpwithinthis. Ornullif there is no match. IfregExpis a string, it is converted to a regular expression before performing the previous steps.The result has the following type:
interface RegExpMatchArray extends Array<string> { index: number; input: string; groups: undefined | { [key: string]: string }; }
Numbered capture groups become Array indices. Named capture groups (ES2018) become properties of
.groups. In this mode,.match()works likeRegExp.prototype.exec().Examples:
> 'ababb'.match(/a(b+)/) [ 'ab', 'b', index: 0, input: 'ababb', groups: undefined ] > 'ababb'.match(/a(?<foo>b+)/) [ 'ab', 'b', index: 0, input: 'ababb', groups: { foo: 'b' } ] > 'abab'.match(/x/) null -
match(regExp: RegExp): string[] | nullES3If flag
/gofregExpis set,.match()returns either an Array with all matches ornullif there was no match.> 'ababb'.match(/a(b+)/g) [ 'ab', 'abb' ] > 'ababb'.match(/a(?<foo>b+)/g) [ 'ab', 'abb' ] > 'abab'.match(/x/g) null -
normalize(form: 'NFC'|'NFD'|'NFKC'|'NFKD' = 'NFC'): string;Normalizes
thisaccording to the Unicode Normalization Forms.
- String.prototype.padEnd( maxLength [ , fillString ] )
- String.prototype.padStart( maxLength [ , fillString ] )
- String.prototype.repeat ( count )
- String.prototype.replace ( searchValue, replaceValue )
- String.prototype.search ( regexp )
- String.prototype.slice ( start, end )
- String.prototype.split ( separator, limit )
- String.prototype.startsWith ( searchString [ , position ] )
- String.prototype.substring ( start, end )
- String.prototype.toLocaleLowerCase ( [ reserved1 [ , reserved2 ] ] )
- String.prototype.toLocaleUpperCase ( [ reserved1 [ , reserved2 ] ] )
- String.prototype.toLowerCase ( )
- String.prototype.toString ( )
- String.prototype.toUpperCase ( )
- String.prototype.trim ( )
- String.prototype.valueOf ( )
- String.prototype [ @@iterator ] ( )
- String methods of various ECMAScript versions in detail: http://exploringjs.com
- https://github.com/Microsoft/TypeScript/blob/master/lib/lib.es6.d.ts
- MDN
- ECMAScript spec
So to replace all '.'
we need to skip the special character like this.