Notifications
Clear all
[Closed] How do fight a Crazy node name?
Page 2 / 2
Prev
Feb 05, 2013 6:11 pm
nope… string.format is worse than mxs:
struct NodeNameExt
(
private
regexClass = dotnetclass "System.Text.RegularExpressions.Regex",
pattern = "[\[\]\\\*'?]",
replacement = "\\$0",
public
fn doubleEnd name end:"'" = end + name + end,
fn insureName name = (doubleEnd (regexClass.Replace name pattern replacement)),
fn executableName name = ("$" + insureName name)
)
Feb 05, 2013 6:11 pm
fun is continuing…
global NodeNameExt
(
struct NodeNameStruct
(
private
regexClass = dotnetclass "System.Text.RegularExpressions.Regex",
pattern = "[\[\]\\\*'?]",
replacement = "\\$0",
public
fn doubleEnd name end:"'" = end + name + end,
fn insureName name = (doubleEnd (regexClass.Replace name pattern replacement)),
fn executableName name = ("$" + insureName name),
fn isLegal name = not (regexClass.IsMatch name pattern),
fn findIllegal nodes =
(
for node in nodes where not isLegal node.name collect node
)
)
NodeNameExt = NodeNameStruct()
ok
)
Page 2 / 2
Prev