Top

[Javascript] REPLACE¸¦ REPLACEALL ó·³ »ç¿ëÇϱâ | Web-Programing
±è°æÈÆ (admin) | Editor | 2018/07/04 11:29:33 | Á¶È¸:5640

ÀÚ¹Ù½ºÅ©¸³Æ®¿¡¼­ replaceAll Àº ¾ø´Ù.
Á¤±Ô½ÄÀ» ÀÌ¿ëÇÏ¿© ´ë»ó ½ºÆ®¸µ¿¡¼­ ¸ðµç ºÎºÐÀ» ¼öÁ¤ÇØ ÁÙ ¼ö ÀÖ´Ù.

[replace ÀÌ¿ë]

?
1
2
// #¸¦ °ø¹éÀ¸·Î º¯°æÇÑ´Ù.
str.replace( "#" , "" );

ÇÏÁö¸¸ ù¹ø° # ¸¸ °ø¹éÀ¸·Î º¯°æÇÏ°í ³ª¸ÓÁö´Â º¯°æÀÌ µÇÁö ¾Ê´Â´Ù.

[Á¤±Ô½Ä ÀÌ¿ëÇؼ­ gi ·Î °¨½Î±â]

?
1
2
3
// #¸¦ °¨½Ñ µû¿ÈÇ¥¸¦ ½½·¡½Ã·Î ´ëüÇÏ°í µÚ¿¡ gi ¸¦ ºÙÀ̸é
// replaceAll °ú °°Àº °á°ú¸¦ º¼ ¼ö ÀÖ´Ù.
str.replace(/ #/gi, "");

[Á¤±Ô½ÄÀÇ gi ¼³¸í]
* g : ¹ß»ýÇÒ ¸ðµç pattern¿¡ ´ëÇÑ Àü¿ª °Ë»ö
* i : ´ë/¼Ò¹®ÀÚ ±¸ºÐ ¾ÈÇÔ
* m: ¿©·¯ ÁÙ °Ë»ö (Âü°í)


Ãâó : http://www.codejs.co.kr/%EC%9E%90%EB%B0%94%EC%8A%A4%ED%81%AC%EB%A6%BD%ED%8A%B8%EC%97%90%EC%84%9C-replace%EB%A5%BC-replaceall-%EC%B2%98%EB%9F%BC-%EC%82%AC%EC%9A%A9%ED%95%98%EA%B8%B0/

°øÀ¯Çϱâ
°øÀ¯Çϱâ
0
0
0


´ñ±ÛÀ» ºÒ·¯¿À´Â ÁßÀÔ´Ï´Ù.
¡ã ÀÌÀü±Û URL, URN, URI ÀÇ Â÷ÀÌÁ¡ ±è°æÈÆ (admin) 2018-07-05 18:11:45
¡å ´ÙÀ½±Û [PHP] ¹è¿­ Áß°£¿¡ Ãß°¡Çϱ⠱è°æÈÆ (admin) 2018-01-10 10:32:50