Notifications
Clear all
[Closed] Regular expression in MAxscript ?
Apr 01, 2011 3:45 pm
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
Apr 01, 2011 3:45 pm
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!
Apr 01, 2011 3:45 pm
Hi Kameleon,
Thx very much for your answer !
didn’t think of .net, but I sure will try !
wiil keep you informed
thx agin
Apr 01, 2011 3:45 pm
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+$"
Apr 01, 2011 3:45 pm
Also try this website when trying to work out the right expression. It’s pretty cool.
Light