Javascript Replace function
How to use the String.replace function
AI
AI 요약: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.
소스 코드
// look for the word 'four' and replace with 'five' for all(g option) occurences // String.replace(/text to find/options,replacement text) sTMP = "see my four assed monkey, see my four assed monkey" sTMP = sTMP.replace(/four/g,"five") // outputted text looks like this // sTMP = "see my five assed monkey, see my five assed monkey" // without the (g) option it would look like this sTMP = "see my four assed monkey, see my four assed monkey" sTMP = sTMP.replace(/four/g,"five") // outputted text looks like this // sTMP = "see my five assed monkey, see my four assed monkey"
원본 댓글 (3)
Wayback Machine에서 복구됨