x


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

ina gravatar image

ina
4.5k 1628 1268 1320

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

1 answer: sort voted first
more ▼

answered May 04, 2012 at 03:12 PM

Berenger gravatar image

Berenger
12.9k 40 45 98

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

May 04, 2012 at 10:17 PM ina

The link to the MonoCompatibility does not work anymore.

Jan 09 at 10:35 AM TheGering

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:
http://unity3d.com/support/documentation/ScriptReference/MonoCompatibility

--> 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:

 //UnityScript
 import System.Text.RegularExpressions;
 
 //C#
 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
(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

By RSS:

Answers

Answers and Comments

Topics:

x933
x686
x84
x22
x6

asked: May 04, 2012 at 07:37 AM

Seen: 8479 times

Last Updated: Jan 09 at 11:04 AM