StringReplace

ÁöÁ¤µÈ ºÎ¹®ÀÚ¿­À» »õ ¹®ÀÚ¿­·Î ±³Ã¼ÇÕ´Ï´Ù.

OutputVar := StrReplace(Haystack, SearchText [, ReplaceText, OutputVarCount, Limit := -1])  ; v1.1.21+
StringReplace, OutputVar, InputVar, SearchText [, ReplaceText, ReplaceAll?]

¸Å°³º¯¼ö

OutputVar

±³Ã¼ÀÇ °á°ú¸¦ ÀúÀåÇÒ º¯¼öÀÇ À̸§.

InputVar ¶Ç´Â Haystack

±×ÀÇ ³»¿ëÀ» ÀÐÀ» º¯¼öÀÇ À̸§. À̸§À» ÆÛ¼¾Æ® »çÀÎÀ¸·Î µÑ·¯ ½ÎÁö ¸¶½Ê½Ã¿À. ´Ü, º¯¼öÀÇ ³»¿ëÀÌ À̸§À̱⸦ ¿øÇÏ´Â °æ¿ì´Â ¿¹¿ÜÀÔ´Ï´Ù.

StrReplace()´Â ÇÔ¼öÀ̹ǷÎ, HaystackÀº Ç¥Çö½ÄÀÌ °¡´ÉÇÕ´Ï´Ù.

SearchText

°Ë»ö¿¡ »ç¿ëµÉ ¹®ÀÚ¿­. ºÎÇÕÀº ´ë¼Ò¹®ÀÚ¸¦ ±¸ºÐÇÏÁö ¾Ê½À´Ï´Ù. ´Ü, StringCaseSense°¡ ÄÑÁ® ÀÖ´Â °æ¿ì´Â ¿¹¿ÜÀÔ´Ï´Ù.

ReplaceText

SearchText´Â ÀÌ ÅؽºÆ®·Î ±³Ã¼µË´Ï´Ù. »ý·«µÇ°Å³ª ºñ¾î ÀÖÀ¸¸é, SearchText´Â ºó ¹®ÀÚ¿­·Î ±³Ã¼µË´Ï´Ù. ´Ù¸¥ ¸»·Î, OutputVar·ÎºÎÅÍ Á¦¿ÜµË´Ï´Ù.

OutputVarCount (StrReplace)

±³Ã¼°¡ ÀϾ Ƚ¼ö¸¦ ÀúÀåÇÒ º¯¼öÀÇ À̸§. ÀοëºÎÈ£ ó¸® ¾ÈÇÔ (¾øÀ¸¸é 0).

Limit (StrReplace)

LimitÀ» »ý·«Çϸé, ±âº»°ªÀº -1ÀÔ´Ï´Ù. ±âº»À¸·Î Haystack ¹ß°ßµÈ ¸ðµç ÆÐÅÏÀ» ±³Ã¼ÇÕ´Ï´Ù. ±×·¸Áö ¾ÊÀ¸¸é, ±³Ã¼¸¦ Çã¿ëÇÒ ÃÖ´ë Ƚ¼ö¸¦ ÁöÁ¤ÇϽʽÿÀ. Haystack¿¡¼­ ¸¶Áö¸· ¸Å°³º¯¼öÀÇ ¿À¸¥ÂÊ ºÎºÐÀº ±³Ã¼µÇÁö ¾Ê°í ±×´ë·ÎÀÔ´Ï´Ù.

ReplaceAll? (StringReplace)

»ý·«Çϸé, ¿ÀÁ÷ SearchTextÀÇ Ã¹ ¹ø° ºÎÇÕ¸¸ ±³Ã¼µË´Ï´Ù. ±×·¯³ª ÀÌ ¸Å°³º¯¼ö°¡ 1À̳ª A ¶Ç´Â AllÀ̸é, ¸ðµç ºÎÇÕÀÌ ±³Ã¼µË´Ï´Ù.

´Ü¾î UseErrorLevelÀ» ÁöÁ¤Çϸé ErrorLevel¿¡ ±³Ã¼µÈ Ƚ¼ö¸¦ ÀúÀåÇÒ ¼ö ÀÖ½À´Ï´Ù (¾øÀ¸¸é 0). UseErrorLevelÀº ¹¬½ÃÀûÀ¸·Î "All".

ErrorLevel

StrReplace: ErrorLevelÀº ¼³Á¤µÇÁö ¾Ê½À´Ï´Ù.

StringReplace: ¸¶Áö¸· ¸Å°³º¯¼ö°¡ UseErrorLevelÀ̸é, ErrorLevel¿¡´Â ±³Ã¼µÈ Ƚ¼ö°¡ ¼³Á¤µË´Ï´Ù (¾øÀ¸¸é 0). ±×·¸Áö ¾ÊÀ¸¸é, ErrorLevelÀº SearchText¸¦ InputVar ¾È¿¡¼­ ¹ß°ßÇÏÁö ¸øÇÑ °æ¿ì 1ÀÌ ¼³Á¤µÇ°í ¹ß°ßÇÑ °æ¿ì´Â 0ÀÌ ¼³Á¤µË´Ï´Ù.

³íÆò

ÀÌ ¸í·É¾î ±×¸®°í ±âŸ ¸ðµç ¸í·É¾î¿¡ ´ëÇÏ¿©, OutputVar´Â InputVar¿Í º¯¼ö°¡ °°¾Æµµ Çã¿ëµË´Ï´Ù.

³»Àå º¯¼ö %A_Space%¿Í %A_Tab%¿¡ °¢°¢ ½ºÆäÀ̽º Çϳª¿Í ÅÇ ¹®ÀÚ Çϳª°¡ µé¾î ÀÖ½À´Ï´Ù. SearchTextÀÇ ¾ÕÀ̳ª µÚ¿¡¼­ ½ºÆäÀ̽º¿Í ÅǸ¸ Ȧ·Î °Ë»öÇÒ ¶§ À¯¿ëÇÕ´Ï´Ù.

v1.0.45¿¡¼­, AllSlow ¿É¼ÇÀº ¼öÇ༺´É Çâ»ó°ú È¿À²ÀûÀÎ ¸Þ¸ð¸® ÀÌ¿ëÀ» À§ÇØ Æó±â µÇ¾ú½À´Ï´Ù. ¿©ÀüÈ÷ ÁöÁ¤ÇÒ ¼ö´Â ÀÖÁö¸¸, ¾Æ¹« È¿°ú°¡ ¾øÀ» °ÍÀÔ´Ï´Ù.

°ü·Ã Ç׸ñ

RegExReplace(), IfInString, StringCaseSense, StringLeft, StringRight, StringMid, StringTrimLeft, StringTrimRight, StringLen, StringLower, StringUpper, StringGetPos, if var is type

¿¹Á¦

; Ŭ¸³º¸µåÀÇ ³»¿ë¿¡¼­ ¸ðµç CR+LF¸¦ Á¦°ÅÇÕ´Ï´Ù:
StringReplace, clipboard, clipboard, `r`n, , All

; ¸ðµç ½ºÆäÀ̽º¸¦ Ç÷¯½º·Î ±³Ã¼ÇÕ´Ï´Ù:
StringReplace, NewStr, OldStr, %A_SPACE%, +, All

; º¯¼ö ¾ÈÀÇ ÅؽºÆ®·ÎºÎÅÍ ¸ðµç ºó ÁÙÀ» Á¦°ÅÇÕ´Ï´Ù:
Loop
{
    StringReplace, MyString, MyString, `r`n`r`n, `r`n, UseErrorLevel
    if ErrorLevel = 0  ; ´õ ÀÌ»ó ±³Ã¼°¡ ÇÊ¿äÇÏÁö ¾Ê½À´Ï´Ù.
        break
}