> For the complete documentation index, see [llms.txt](https://docs.hidemium.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.hidemium.io/hidemium-4/iv.-tu-dong-hoa-automation-and-ai/automation-advance/cach-get-text-roi-group-toan-bo-text-va-lai-tach-tung-text-ra-bang-automation.md).

# CÁCH GET TEXT RỒI GROUP TOÀN BỘ TEXT VÀ LẠI TÁCH TỪNG TEXT RA BẰNG AUTOMATION

Có rất nhiều trường hợp bạn cần sử dụng phương pháp nâng cao group text lại rồi lại phải tách ra để sử dụng trong các bước tiếp theo của script. Hôm nay Hidemum sẽ hướng dẫn một use case cụ thể và hy vọng từ ví dụ thực tế này bạn có thể tự sáng tạo theo cách riêngcủa mình nhé

Use case cụ thể lần này là tạo ví ronin.

OK. Bỏ qua các bước click và tạo pass, đến phần check “Recovery Phrase” chúng ta cần cop hết 12 chữ này ra, chính vì vậy ngoài biến get đừng chữ ra 1, ta cần có 1 biến tổng chứa tất cả chữ này. Trên script làm như sau :

<figure><img src="/files/yLcB2dgymVl8Th4AMsT8" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/wxsbnSuhTElWLugiCyMb" alt=""><figcaption></figcaption></figure>

Sơ đồ phân đoạn lấy text và nối text

<figure><img src="/files/EN2bdpwlRjIyxEvUDaO3" alt=""><figcaption></figcaption></figure>

Mình chọn lặp theo element. Đây là element để lấy chữ

<figure><img src="/files/SYK1tp45JMdaBUZZ6YOq" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/8c6tr7q5uEb7c3D1KLIG" alt=""><figcaption></figcaption></figure>

Dùng SET VARIABLE tự động tăng thêm 1 khi lặp vòng mới.

<figure><img src="/files/o8JviGnrp2HVOHfYopUI" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/qzUtXVWzD0tWBkQeHvPf" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/9LK8z9AAauz67xYSJAUu" alt=""><figcaption></figcaption></figure>

Node chính là Get text, thì dùng luôn element lấy text đẻ trong vòng for đó, vị trí chính là biến được tăng kia, vì số thứ tự khi lặp theo element trong for là bắt đầu từ 0, mà vị trí element trong các node lại bắt đầu từ 1, cho nên phải + 1 trước khi dùng để get text. Ở đây nếu lặp vòng 2, tức là 1 rồi +1 =2, thì lúc này, element sẽ ở vị trí 2, kết quả là biến Key lấy được chữ ” fortune”

<figure><img src="/files/jQqcKbbCCJiMewo4cpij" alt=""><figcaption></figcaption></figure>

Sau đó tạo một biến mới “Recovery\_Phrase”, dùng SET VARIABLE nối với biến Key lấy đuộc từ node GET TEXT. Kết quả sau 12 vòng lặp sẽ là biến “Recovery\_Phrase” = danger fortune wash reduce defy slide essence post neutral sing travel razor\
\=> hoàn thành việc gộp các biến nhỏ vào 1 biến lớn.

<figure><img src="/files/D35Ge5k62Ojz6uKdjtKJ" alt=""><figcaption></figcaption></figure>

Nhưng sau đấy đến bước tiếp theo ta vẫn cần tách biến này ra để “Confirm Seed Phrase”

<figure><img src="/files/p5Zj3sqOuVW6M4JpOMzS" alt=""><figcaption></figcaption></figure>

Sơ đồ phân đoạn tách text và nhập

<figure><img src="/files/GlhhHoQqDQJDINKdHz1F" alt=""><figcaption></figcaption></figure>

Tương tự như ở trên, đoạn này là tìm xem có bao nhiêu element đánh số thứ tự như này và rồi dùng SET VARIABLE cộng thêm 1

<figure><img src="/files/9UZcKISYVUeBIgjojfwG" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/JGNcwyXRTuNImeMifNOx" alt=""><figcaption></figcaption></figure>

Cũng lại dùng GET TEXT và đặt tên là “insert\_key” và để vị trí thay đổi theo index2 ( biến từ vòng lặp ).

<figure><img src="/files/D595SYYriAwnZEAasGea" alt=""><figcaption></figcaption></figure>

Ở đây là mình muốn lấy số 1 4 8 10 này. Cái này tương đương với vị trí của text trong đoạn coppy trên, cho nên cần lấy nó để xác định là nên nhập chữ ở vị trí số mấy

<figure><img src="/files/fXkq3LYHag9f5amWD9VW" alt=""><figcaption></figcaption></figure>

Tiếp theo đến node eval, node này chỉ xuất hiện trong ví dụ cụ thể này thôi nha vì Text lấy được là #2 #4 #8 #10 cho nên cần xử lý qua Eval để tách từ này ra thành # và 2, và chọn output ra số 2

<figure><img src="/files/dNeILHbVYFACS32BwZ4F" alt=""><figcaption></figcaption></figure>

code :&#x20;

```
var str = insert_key;
var matches = str.match(/(\D+)(\d+)/);
if (matches) {
var nonNumberPart = matches[1]; // “#”
var numberPart = matches[2]; // “2”
console.log(“Phần không phải số: ” + nonNumberPart);
return numberPart;
} else {
console.log(“Không tìm thấy kết quả phù hợp”);
```

\
Đến node EVAL này mới dùng để tách đoạn text kia ra. Logic là từ biến ok ( tức là biến sau khi tách # và 2, ok = 2 ) kia để xác định từ sẽ lấy trong biến “Recovery\_Phrase”, nên chỗ này Inject 2 biến “ok” và “Recovery\_Phrase” vào. Và output là kết quả từ được lấy trong đoạn này.

<figure><img src="/files/HOMcKSRb53DWdgpDR178" alt=""><figcaption></figcaption></figure>

CODE:

```
function findWordAtIndex(sentence, index) {
let words = sentence.split(” “);
if (index >= 0 && index < words.length) {
return words[index];
} else {
return “Vị trí không hợp lệ”;
}
}
let sentence = Recovery_Phrase; // Câu cần tìm từ
let index = ok; // Vị trí của từ
let word = findWordAtIndex(sentence, index);
return word; // In ra từ ở vị trí index trong câu sentence
```

Rồi dùng node SEND TEXT để nhập từ đã lấy thành công là xong. Cứ như vậy lặp lại quy trình này 4 lần là nhập thành công những từ cần xác minh để hoàn thành kịch bản auto tạo acc ronin.

<figure><img src="/files/SoegLm9gD1eHBmIIktKs" alt=""><figcaption></figcaption></figure>

II. Tách 1 cụm text thành từng từ một\
Ví dụ bạn có 1 biến Full\_text = danger fortune wash reduce defy slide essence post neutral sing travel razor. Sau đó muốn tách từng từ ra một. Thì tiếp tùng dùng eval nhé.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.hidemium.io/hidemium-4/iv.-tu-dong-hoa-automation-and-ai/automation-advance/cach-get-text-roi-group-toan-bo-text-va-lai-tach-tung-text-ra-bang-automation.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
