An warware: javascript ya maye gurbin duk sarari

Babban matsalar maye gurbin duk sarari da harafi ษ—aya shine yana iya haifar da matsala lokacin da aka kwafi da liฦ™a rubutu.

 with underscore

var str = "javascript replace all space with underscore";
str = str.replace(/ /g, "_");

Wannan layin lambar yana maye gurbin duk sarari a cikin kirtani "javascript maye gurbin duk sararin samaniya tare da ฦ™aranci" tare da ฦ™ararrawa.

Sauya a javascript

Sauya aiki ne a cikin JavaScript wanda ke ษ—aukar gardama biyu. Hujja ta farko ita ce zaren da za a maye gurbinsa kuma hujja ta biyu ita ce zaren maye.

Yin aiki tare da maye gurbin da rubutu

A cikin JavaScript, zaku iya amfani da ayyukan maye gurbin () da ayyukan rubutu () don maye gurbin rubutu a cikin kirtani.

Ayyukan maye gurbin () yana maye gurbin duk abin da ya faru na kirtani a cikin kirtani tare da wani kirtani. Aikin rubutu() yana mayar da rubutun kirtani, ba tare da wani tsari ba.

Shafi posts:

Leave a Comment