# Langchain: text splitter behavior

**URL:** <https://community.deeplearning.ai/t/langchain-text-splitter-behavior/376599>\
**Category:** LangChain for LLM Application Development\
**Tags:** langchain\
**Created:** [July 6, 2023, 9:48pm UTC](https://community.deeplearning.ai/t/langchain-text-splitter-behavior/376599 "2023-07-06T21:48:24Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![GreenEye](https://avatars.discourse-cdn.com/v4/letter/g/838e76/32.png) [@GreenEye](https://community.deeplearning.ai/u/GreenEye)\
**Post date:** [July 6, 2023, 9:48pm UTC](https://community.deeplearning.ai/t/langchain-text-splitter-behavior/376599/1 "2023-07-06T21:48:24Z")

</div>

I don’t understand the behavior of Langchain recursive text splitter. Here is my code and output.

```auto
from langchain.text_splitter import RecursiveCharacterTextSplitter
r_splitter = RecursiveCharacterTextSplitter(
    chunk_size=10,
    chunk_overlap=0,
# separators=["\n"]#, "\n", " ", ""]
)
test = """a\nbcefg\nhij\nk"""
print(len(test))
tmp = r_splitter.split_text(test)
print(tmp)

```

Output

```auto
13
['a\nbcefg', 'hij\nk']

```

As you can see, it outputs chunks of size 7 and 5 and only splits on one of the new line characters. I was expecting output to be [‘a’,‘bcefg’,‘hij’,‘k’]

---

<div class="post-metadata">

**Author:** ![TMosh](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/tmosh/32/9321_2.png) [@TMosh](https://community.deeplearning.ai/u/TMosh)\
**Post date:** [July 6, 2023, 10:06pm UTC](https://community.deeplearning.ai/t/langchain-text-splitter-behavior/376599/2 "2023-07-06T22:06:53Z")

</div>

I have moved your thread out of the “General Discussions” area, and put it in what I think is the correct forum area.

---

<div class="post-metadata">

**Author:** ![GreenEye](https://avatars.discourse-cdn.com/v4/letter/g/838e76/32.png) [@GreenEye](https://community.deeplearning.ai/u/GreenEye)\
**Post date:** [July 7, 2023, 3:15am UTC](https://community.deeplearning.ai/t/langchain-text-splitter-behavior/376599/3 "2023-07-07T03:15:13Z")

</div>

Thanks. It should ideally be under the Short Course: Langchain Chat with your Data, but I cannot find that section here.

---

<div class="post-metadata">

**Author:** ![GreenEye](https://avatars.discourse-cdn.com/v4/letter/g/838e76/32.png) [@GreenEye](https://community.deeplearning.ai/u/GreenEye)\
**Post date:** [July 7, 2023, 1:59pm UTC](https://community.deeplearning.ai/t/langchain-text-splitter-behavior/376599/4 "2023-07-07T13:59:25Z")

</div>

Asked this question on stack overflow and got the answer  
[https://stackoverflow.com/questions/76633711/langchain-text-splitter-behavior](https://stackoverflow.com/questions/76633711/langchain-text-splitter-behavior)
