_replace_new_line() — langchain Function Reference
Architecture documentation for the _replace_new_line() function in json.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 38ec0623_4c04_9c75_1045_b54336f01990["_replace_new_line()"] 20a5fe84_8249_f1df_53f0_7f22870f123f["json.py"] 38ec0623_4c04_9c75_1045_b54336f01990 -->|defined in| 20a5fe84_8249_f1df_53f0_7f22870f123f 38ec0623_4c04_9c75_1045_b54336f01990["_replace_new_line()"] 38ec0623_4c04_9c75_1045_b54336f01990 -->|calls| 38ec0623_4c04_9c75_1045_b54336f01990 38ec0623_4c04_9c75_1045_b54336f01990["_replace_new_line()"] 38ec0623_4c04_9c75_1045_b54336f01990 -->|calls| 38ec0623_4c04_9c75_1045_b54336f01990 style 38ec0623_4c04_9c75_1045_b54336f01990 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/core/langchain_core/utils/json.py lines 15–30
def _replace_new_line(match: re.Match[str]) -> str:
"""Replace newline characters in a regex match with escaped sequences.
Args:
match: Regex match object containing the string to process.
Returns:
String with newlines, carriage returns, tabs, and quotes properly escaped.
"""
value = match.group(2)
value = re.sub(r"\n", r"\\n", value)
value = re.sub(r"\r", r"\\r", value)
value = re.sub(r"\t", r"\\t", value)
value = re.sub(r'(?<!\\)"', r"\"", value)
return match.group(1) + value + match.group(3)
Domain
Subdomains
Defined In
Calls
Called By
Source
Frequently Asked Questions
What does _replace_new_line() do?
_replace_new_line() is a function in the langchain codebase, defined in libs/core/langchain_core/utils/json.py.
Where is _replace_new_line() defined?
_replace_new_line() is defined in libs/core/langchain_core/utils/json.py at line 15.
What does _replace_new_line() call?
_replace_new_line() calls 1 function(s): _replace_new_line.
What calls _replace_new_line()?
_replace_new_line() is called by 1 function(s): _replace_new_line.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free