Escaping special regex characters?

I am trying to assign a value to a variable (using Assign) however my formula will not validate.

the regex string is [^\\]+(?=\.xlsb$)

I have tried all of the following with no success:

Regex.Match(file_address,[^\\]+(?=\.xlsb$)).Value
Regex.Match(file_address,"[^\\]+(?=\.xlsb$)").Value
Regex.Match(file_address,@"[^\\]+(?=\.xlsb$)").Value
Regex.Match(file_address,"[^\\]+(?=\.xlsb$)").Groups(0).Value
Regex.Match(file_address,"[^\\]+(?=\.xlsb$)").Groups(1).Value

The problem appears to be around the + character.

Any help would be much appreciated

Alternatively if there is a way to get UIpath to play nicely with excel binaries that would be useful too.

Thanks

1 Like

The expression looks correct. Have you tried including a multiple lines flag, in order to ensure that the $ validates?

System.Text.RegularExpressions.Regex.Match(file_address, “[^\]+(?=.xlsb$)”,system.Text.RegularExpressions.RegexOptions.Multiline).Value

Useful sites:

1 Like