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 '12 at 07:37 AM

ina gravatar image

4.2k 591 644 684

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

1 answer: sort voted first
more ▼

answered May 04 '12 at 03:12 PM

Berenger gravatar image

12.4k 15 21 63

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

May 04 '12 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 '12 at 10:42 PM Bunny83

The link to the MonoCompatibility does not work anymore.

Jan 09 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 '12 at 07:37 AM

Seen: 5603 times

Last Updated: Jan 09 at 11:04 AM