🛠️ToolsShed

문자열 이스케이프 / 언이스케이프

JSON, JavaScript, HTML용 문자열을 이스케이프하거나 되돌립니다.

StringEscape.jsonDesc

StringEscape.cheatsheet

\\\
"\"
newline\n
tab\t
carriage return\r
backspace\b
form feed\f

자주 묻는 질문

코드 구현

import json
import html
import re

text = 'Hello "world"\nLine 2 & <tag>'

# JSON string escaping
json_escaped = json.dumps(text)
print(json_escaped)
# '"Hello \"world\"\nLine 2 & <tag>"'

# Python repr (Python string literal escaping)
py_escaped = repr(text)
print(py_escaped)
# '\'Hello "world"\nLine 2 & <tag>\''

# HTML escaping
html_escaped = html.escape(text)
print(html_escaped)
# 'Hello &quot;world&quot;\nLine 2 &amp; &lt;tag&gt;'

# Regex escaping (escape metacharacters for use in pattern)
regex_escaped = re.escape("price: $4.99 (USD)")
print(regex_escaped)
# 'price:\ \$4\.99\ \(USD\)'

Comments & Feedback

Comments are powered by Giscus. Sign in with GitHub to leave a comment.