Advertisement
C_Volume2 String Manipulation #81137

Javascript Replace function

How to use the String.replace function

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.

सोर्स कोड
original-source
// 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 से पुनर्प्राप्त