# RUTA script for extracting 37 digits string

**URL:** <https://forums.pega.com/t/ruta-script-for-extracting-37-digits-string/7091>\
**Category:** General\
**Tags:** financial-services, decision-management, pega-customer-decision-hub\
**Created:** [May 24, 2024, 2:34pm UTC](https://forums.pega.com/t/ruta-script-for-extracting-37-digits-string/7091 "2024-05-24T14:34:03Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Himalaya\_Sudan](https://avatars.discourse-cdn.com/v4/letter/h/87869e/32.png) [@Himalaya\_Sudan](https://forums.pega.com/u/Himalaya_Sudan)\
**Post date:** [May 24, 2024, 2:34pm UTC](https://forums.pega.com/t/ruta-script-for-extracting-37-digits-string/7091/1 "2024-05-24T14:34:03Z")

</div>

Hi All,

I need assistance for extracting a string from an incoming email which of form:

Test Ref(s) : ABxxx

Where xxx - 35 digit number

OR

Test Ref(ABCD) : 37 Digital alphanumeric string

Can anybody pls help with the RUTA script.

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![MarijeSchillern](https://yyz2.discourse-cdn.com/pega/user_avatar/forums.pega.com/marijeschillern/32/23321_2.png) [@MarijeSchillern](https://forums.pega.com/u/MarijeSchillern)\
**Post date:** [June 7, 2024, 8:59am UTC](https://forums.pega.com/t/ruta-script-for-extracting-37-digits-string/7091/2 "2024-06-07T08:59:49Z")

</div>

@Himalaya Sudan to extract the patterns you mentioned, you can use the following RUTA scripts:  
For “Test Ref(s) : ABxxx” where xxx is a 35 digit number:

“Test Ref(s) : AB” NUM{REGEXP(“.{35}”) → MARK(EntityType)}

For "Test Ref(ABCD) : " followed by a 37 digit alphanumeric string:

“Test Ref(ABCD) : " (W|NUM){REGEXP(”.{37}") → MARK(EntityType)}

Please replace EntityType with the actual entity type you are using. These scripts will mark the entire string including the prefix as the entity. If you want to mark only the number or alphanumeric string, adjust the MARK function accordingly.

⚠ This is a GenAI-powered tool. All generated answers require validation against the provided references.

[NLP With Ruta Script](https://support.pega.com/question/nlp-ruta-script)

[Detecting transaction details with Ruta \> Detecting alphanumeric strings with a fixed number of characters](https://docs.pega.com/bundle/platform/page/platform/decision-management/detect-transaction-details-ruta.html)

[Creating entity extraction model using Ruta script \> Scenario](https://academy.pega.com/challenge/creating-entity-extraction-model-using-ruta-script/v3/in/60101)

[Best practices for pattern extraction in text analytics](https://docs.pega.com/bundle/platform/page/platform/decision-management/best-practices-pattern-extraction.html)

—\> Can you confirm you’ve checked available resources?

[Modifying Apache Ruta scripts to extract custom structured entities](https://docs.pega.com/bundle/platform/page/platform/decision-management/modify-apache-ruta-scripts-entities.html)

[Detecting transaction details with Ruta](https://docs.pega.com/bundle/platform/page/platform/decision-management/detect-transaction-details-ruta.html)

[Creating entity extraction model using Ruta script](https://academy.pega.com/challenge/creating-entity-extraction-model-using-ruta-script/v1?)
