' -------------------------------------------------------- ' Function Name : regular_replace ' Description : Á¤±ÔÇ¥Çö½ÄÀ» ÀÌ¿ëÇÑ ´ëÄ¡ ' -------------------------------------------------------- Function eregi_replace(pattern, replace, text)
Dim eregObj
Set eregObj= New RegExp eregObj.Pattern= pattern ' Set Pattern(ÆÐÅÏ ¼³Á¤) eregObj.IgnoreCase = True ' Set Case Insensitivity(´ë¼Ò¹®ÀÚ ±¸ºÐ ¿©ºÎ) eregObj.Global= True ' Set All Replace(Àüü ¹®¼¿¡¼ °Ë»ö)
eregi_replace = eregObj.Replace(text, replace) ' Replace String
End Function
' -------------------------------------------------------- ' Function Name: auto_link ' Description: ¹®¼¿¡ ÀÖ´Â Url¸¦ ã¾Æ³»¾î ÀÚµ¿À¸·Î ¸µÅ© ' -------------------------------------------------------- Function auto_link(text)
Dim regex_file, regex_http, regex_mail regex_file= "gz|tgz|tar|gzip|zip|rar|mpeg|mpg|exe|rpm|dep|rm|ram|asf|ace|viv|avi|mid|gif|jpg|png|bmp|eps|mov" regex_http = "(http|https|ftp|telnet|news):\/\/(([\xA1-\xFEa-z0-9_\-]+\.[][\xA1-\xFEa-z0-9:;&#@=_~%\?\/\.\,\+\-]+)(\/|[\.]*[a-z0-9]))" regex_mail = "([\xA1-\xFEa-z0-9_\.\-]+)@([\xA1-\xFEa-z0-9_\-]+\.[a-z0-9\-\._\-]+[\.]*[\xA1-\xFEa-z0-9\?=]*)"
' img tag ¿Í a tag ÀÇ °æ¿ì ¸µÅ©°¡ ¿©·¯ÁÙ¿¡ °ÉÃÄ ÀÌ·ç¾îÁ® ÀÖÀ» °æ¿ì ' À̸¦ ÇÑÁÙ·Î ÇÕħ (ÇÕÄ¡¸é¼ ºÎ°¡ ¿É¼ÇµéÀº ¸ðµÎ »èÁ¦ÇÔ) 'text = eregi_replace("<(a|img)[^>]*(href|src)[^>]*(" & regex_http & "|mailto:" & regex_mail & ")[^>]*>","<$1 $2=""$3"">", text) text = eregi_replace("<(a)[^>]*(href)[^>]*(" & regex_http & "|mailto:" & regex_mail & ")[^>]*>","<$1 $2=""$3"">", text)
' Ư¼ö¹®ÀÚ¿Í ¸µÅ©½Ã target »èÁ¦ text = eregi_replace("&(quot|gt|lt)","!$1", text)
' html »ç¿ë½Ã Link º¸È£ text = eregi_replace("href=""(" & regex_http & ")""[^>]*>","href=""$2_orig://$3"" target=""_blank"">", text) text = eregi_replace("href=""mailto:(" & regex_mail & ")"">","href=""mailto:$2#-#$3"">", text) text = eregi_replace("(background|codebase|src)[ \n]*=[\n""' ]*(" & regex_http & ")[""']*","$1=""$3_orig://$4""",text)
'¸µÅ©°¡ ¾ÈµÈ Url¹× Email Address ÀÚµ¿ ¸µÅ© text = eregi_replace("(" & regex_http & ")" ,"<a href=""$1"" target=""_blank"">$1</a>", text) text = eregi_replace("(" & regex_mail & ")","<a href=""mailto:$1"">$1</a>", text)
' º¸È£¸¦ À§ÇØ Ä¡È¯µÈ°Í º¹±¸ text = eregi_replace("!(quot|gt|lt)","&$1", text) text = eregi_replace("(http|https|ftp|telnet|news|mms)_orig","$1", text) text = eregi_replace("#-#","@",text)
' File Link½Ã TargetÀ» »èÁ¦ text = eregi_replace("(\.(" & regex_file & ")"") target=""_blank""","$1", text) auto_link = text
End Function
Response.Write auto_link("¿©±â¿¡¿øÇÏ´ÂÅؽºÆ®¸¦ ³ÖÀ¸¼¼¿ä")
ÆÛ¿È. °ËÁõ ¾ÈµÊ. Á¤±Ô½ÄÀº RegexBuddy ·Î ÀϺΠ°ËÁõµÊ.
|
|
|