Before updating to Windows 10 you may need to return your Pro license. More information here

Regular Expressions in Unity

Is there a way to evaluate regular expressions in Unity?

Updated, I'm not sure how to integrate the .net RegEx library exactly. Suppose I have a unity string, how do I get the Regex library to parse it into an array?

more ▼

asked May 04, 2012 at 07:37 AM

avatar image

5.2k 1646 1293 1346

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first
more ▼

answered May 04, 2012 at 03:12 PM

avatar image

13.9k 47 52 119

n00b question about integrating other .net libraries... how do you integrate them?

May 04, 2012 at 10:17 PM ina

The centerpiece of text processing with regular expressions is the regular expression engine, which is represented by the System.Text.RegularExpressions.Regex object

Next step is to check if Unitys Mono version supports this class:

--> result: Yes it is supported except in the micro version. As a note: the Regex class and the System.Text.RegularExpressions namespace is at the very bottom of the page, so you have to wait until it's loaded which can take a while since the page is huge!

Since the class is supported you just have to import the namespace or use the full classname.

Import the namespace:

 import System.Text.RegularExpressions;
 using System.Text.RegularExpressions;
 // Use the Regex class:
 myString = Regex.Replace(myString, "*regular expression*", String.Empty);

Or Using the full classname

 myString = System.Text.RegularExpressions.Regex.Replace(myString, "*regular expression*", String.Empty);

You work quite a long time with Unity and you still don't understand the basic idea of namespaces? Hopefully you get it now ;)

May 04, 2012 at 10:42 PM Bunny83

The link to the MonoCompatibility does not work anymore.

Jan 09, 2014 at 10:35 AM TheGering
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments



asked: May 04, 2012 at 07:37 AM

Seen: 11577 times

Last Updated: Jan 09, 2014 at 11:04 AM