Notifications
Clear all

[Closed] Regular expression in MAxscript ?

Hello,
For a project i am working on, i need to translate the following regular expression:

".+_-?\\d+_-?\\d+_-?\\d+_depth_-?\\d+$"

obviously there’s no regex in MaxScript…

How would you go about this ?
any help/hents most welcome

7 Replies

Have you tried searching for a .NET solution?

Sorry, it took me some time but here you go:

pattern =@"\s+"
	input =  "This is       text with        far  too       much       whitespaces"
	rgx = dotnetObject "System.Text.RegularExpressions.Regex" pattern
	result = rgx.Replace input " "
	print input
	print result

Now I really dont know what you want to do so if you need extra help just post more info on what you want to do. Cheers!

Hi Kameleon,
Thx very much for your answer !
didn’t think of .net, but I sure will try !
wiil keep you informed
thx agin

Works like a charm !
here is my code:

str = "maps/nature/water_canals_water2_0_0_1009_depth_39"
rgx = dotnetObject "System.Text.RegularExpressions.Regex" ""
found = rgx.IsMatch str ".+_-?\\d+_-?\\d+_-?\\d+_depth_-?\\d+$"

Great! Glad to ear that

Also try this website when trying to work out the right expression. It’s pretty cool.

Light

If I see, Mxs [b]matchPattern/b function can helps too.