쓸만한 주저리

[ASP]따옴표 사이에 있는 쉼표를 변환하는 정규표현식

봄돌73 2008. 12. 29. 15:24
참조 : http://www.ihelpers.co.kr/programming/tipntech.php?CMD=view&IDX=21
참조 : http://playgame.egloos.com/936440
참조 : http://fillgun.tistory.com/68?srchid=BR1http%3A%2F%2Ffillgun.tistory.com%2F68


txt="""" & "앨범1,앨범2,앨범3,앨범4" & """" & "," & "가수1" & "," & """" & "제목1,제목2,제목3,제목4" & """"

Set regchk = New RegExp

regchk.IgnoreCase = True
regchk.global = True

'따옴표(")를 제외한 모든 문자
regchk.Pattern = """" & "[^""""]*" & """"

if regchk.test(txt) then
  set quots=regchk.Execute (txt)
end if

for each item in quots
  response.write txt & "<br>"
  response.write item & "<br>"
  txt=replace(txt,item,replace(item,",",","))
  response.write txt & "<br>"
  response.write "<br>"
next

Set regchk = Nothing