# Error with regex expression

**URL:** <https://forum.uipath.com/t/error-with-regex-expression/742529>\
**Category:** Studio\
**Tags:** tools, question, studio\
**Created:** [May 21, 2024, 5:09pm UTC](https://forum.uipath.com/t/error-with-regex-expression/742529 "2024-05-21T17:09:26Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![amanda.gondim](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/amanda.gondim/32/497392_2.png) [@amanda.gondim](https://forum.uipath.com/u/amanda.gondim)\
**Post date:** [May 21, 2024, 5:09pm UTC](https://forum.uipath.com/t/error-with-regex-expression/742529/1 "2024-05-21T17:09:26Z")

</div>

![image](https://global.discourse-cdn.com/uipath/original/4X/e/7/7/e77507e73cc895b7cfc8cfa36ffbdd586d66b834.png)  
my expression is: String.Join(“,”,System.Text.RegularExpressions.Regex.Matches(txtPython,“[.\*]”,RegexOptions.MultiLine).Cast(Of Match).Select(Function(x) x.value))

---

<div class="post-metadata">

**Author:** ![Baskar\_Gurumoorthy](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/baskar_gurumoorthy/32/220429_2.png) [@Baskar\_Gurumoorthy](https://forum.uipath.com/u/Baskar_Gurumoorthy)\
**Post date:** [May 21, 2024, 5:11pm UTC](https://forum.uipath.com/t/error-with-regex-expression/742529/2 "2024-05-21T17:11:17Z")

</div>

> [@amanda.gondim](#):
>
> String.Join(“,”,System.Text.RegularExpressions.Regex.Matches(txtPython,“[.\*]”,RegexOptions.MultiLine).Cast(Of Match).Select(Function(x) x.value))

Hi @amanda.gondim  
can you try with below expression.

Dim result As String = String.Join(“,”, System.Text.RegularExpressions.Regex.Matches(txtPython, “[.\*?]”, RegexOptions.MultiLine).Cast(Of Match)().Select(Function(x) x.Value))

hope it works!!!

---

<div class="post-metadata">

**Author:** ![ashokkarale](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/ashokkarale/32/474400_2.png) [@ashokkarale](https://forum.uipath.com/u/ashokkarale)\
**Post date:** [May 21, 2024, 5:52pm UTC](https://forum.uipath.com/t/error-with-regex-expression/742529/3 "2024-05-21T17:52:57Z")

</div>

@amanda.gondim,

I’m not getting the exact error from screenshot due to language barrier but if the error is saying that Regex is not declared then import this namespace  
`System.Text.RegularExpressions`  
from Import panel on the bottom of the workflow.

Thanks,  
Ashok 🙂

---

<div class="post-metadata">

**Author:** ![ppr](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/ppr/32/464097_2.png) [@ppr](https://forum.uipath.com/u/ppr)\
**Post date:** [May 21, 2024, 6:03pm UTC](https://forum.uipath.com/t/error-with-regex-expression/742529/4 "2024-05-21T18:03:36Z")

</div>

we would recommend importing the System.Text.RegularExpressions namespace  
 ![RegexImport](https://global.discourse-cdn.com/uipath/original/4X/c/2/6/c2685c6b567f6d5fb9a97fcaef5dd46718e9ca6e.png)

Then you can shorten also the statement to:

```auto
String.Join(",",Regex.Matches(txtPython,"\[.*\]",RegexOptions.MultiLine).Cast(Of Match).Select(Function(x) x.value))

```

---

<div class="post-metadata">

**Author:** ![postwick](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/postwick/32/227083_2.png) [@postwick](https://forum.uipath.com/u/postwick)\
**Post date:** [May 21, 2024, 7:55pm UTC](https://forum.uipath.com/t/error-with-regex-expression/742529/5 "2024-05-21T19:55:13Z")

</div>

Did you copy/paste the System.Text.RegularExpressions part? Don’t copy/paste expressions like that. You have to type them out so it’ll do the imports. Copy what you have here, paste it into Notepad to save it, clear out the expression in the Assign, and click Save. Then edit it and type the entire expression manually.
