regex - part of a regular expression not matching in javascript -



regex - part of a regular expression not matching in javascript -

i posted in question think seperate , made another.

the replace method has regular expressions in it. expressions match correctly , replace. replace(/\(he\/\she\)/g,"he") , replace(/\(he\/\she\)/g,"she")

dont replace... dont know why. here code.

function replacegender(name, gender, comment) { if(gender == "m") { comment = comment.replace(/\(name\)/g, name).replace(/\(he\/she\)/g,"he").replace(/\(his\/\her\)/g,"his").replace(/\(his\/\her\)/g,"his").replace(/\(he\/\she\)/g,"he").replace(/\(him\/\her\)/g,"him"); } else if(gender == "f") { comment = comment.replace(/\(name\)/g, name).replace(/\(he\/she\)/g,"she").replace(/\(his\/\her\)/g,"her").replace(/\(his\/\her\)/g,"her").replace(/\(he\/\she\)/g,"she").replace(/\(him\/\her\)/g,"her"); } homecoming comment; };

here input "she reads , confidence. writing skills level. i'm sure if jenna continues work hard (he/she) become strong english language speaker in future."

everything els replaced fine.. (he/she)

/\(he\/\she\)/g replace "(he/ he)" (because \s matches whitespace).

it should /\(he\/she\)/g if want replace "(he/she)".

javascript regex replace

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -