Active IQ Unified Manager Discussions

## Using \ or \\ in User input

Hi,

I need to have a user specify a UNC path in the user input, but it's failing with the error: illegal escape sequence: C

If I add an extra \ it works.  \\\myserver.mydomain.net\\Folder1

Is there a way to make it work so that the user doesn't have to add the extra \  ?

I'm using WFA 3.1SP2

Thanks

Philip

4 REPLIES 4

## Re: Using \ or \\ in User input

Hi Philip,

I have a solution for you (maybe not the best method) but it can be used to work around the MVEL\Java escape character issue.

First of all create a custom MVEL function called replace. EG

```def replace(input, find, replace){
return input.replace(find, replace)
}```

Then you can use this function in combination with the default "SplitByDelimiter" function. For example, consider the UNCPath:

"\\vserver1\share1\$"

Note: The UNCPath input parameter MUST be in quotes. EG:

The MVEL to return the Vserver Name from the UNC Path input parameter, the MVEL expression is:

`splitByDelimiter(replace(replace(\$UncPath, "\\", "="), "==", ""), "=", 0)`

Note: I first replace backslashes with an equals character (as this in an invalid charachter in a UNCPath). This is done first before removing the double equals characters at the start of the remaining string then splitting it on the equals character. If you want to return the CIFS share name then:

`splitByDelimiter(replace(replace(\$UncPath, "\\", "="), "==", ""), "=", 1)`

You can use this example command with a single input parameter (UNCPath) to test it.

```Param(
[Parameter(Mandatory=\$True, HelpMessage="The UNC Path of the CIFS share")]
[String]\$UncPath
)```

Set the string Command's "string expression" to display the UNCPath input parameter:

Then in your workflow when you assign a variable to the comand enter the MVEL expression:

`splitByDelimiter(replace(replace(\$UncPath, "\\", "="), "==", ""), "=", 0)`

Hope that helps

/Matt

If this post resolved your issue, help others by selecting ACCEPT AS SOLUTION or adding a KUDO.

## Re: Using \ or \\ in User input

Hi Matt,

When I saw that the string needs to be in quotes, I tried that without changing any of my code and it works.

So looks like the issue is there.  Is there a way to take the string entered by the user and add the quotes myself?

I hate relying on the user to input the quotes, I know lots of them will forget it.

## Re: Using \ or \\ in User input

Hi Philip,

Unfortunately i do not think there is any workaround for this (that i'm aware of). A UNC path input paramater to a workflow must contain quotes around it.

This is a Java\MVEL limitation. I'd suggest adding a description and a default value (in quotes) to the input parameter. EG

/Matt

If this post resolved your issue, help others by selecting ACCEPT AS SOLUTION or adding a KUDO.

## Re: Using \ or \\ in User input

Thanks Matt, I'll add a description.