![]() |
String Function 'Like' and Special Characters
I'm trying to find string values that start with a bracket ("[") character. However, I know the bracket character serves a special purpose in regular expressions and string functions.
For example, the first rKeyName.Value is "[paths]", but in the following code snippet; the IF statement produces an error and all combinations of apostrophes, quotes, and backslashes that I have tried don't match "[paths]". VB: ------------------------------------------------------------------------------ For Each rKeyName In rKeySection If rKeyName.Value Like "[*" Then strKeySection = rKeyName.Value Else strKeyName = rKeyName.Value strKeyValue = rKeyName.Offset(0, 1).Value oConfigData.Add strKeySection, strKeyName, strKeyValue End If Next ------------------------------------------------------------------------------ Thanks in advance, Carl |
String Function 'Like' and Special Characters
Hi
try If rKeyName.Value Like "~[*" Then -----Original Message----- I'm trying to find string values that start with a bracket ("[") character. However, I know the bracket character serves a special purpose in regular expressions and string functions. For example, the first rKeyName.Value is "[paths]", but in the following code snippet; the IF statement produces an error and all combinations of apostrophes, quotes, and backslashes that I have tried don't match "[paths]". VB: ---------------------------------------------------------- -------------------- For Each rKeyName In rKeySection If rKeyName.Value Like "[*" Then strKeySection = rKeyName.Value Else strKeyName = rKeyName.Value strKeyValue = rKeyName.Offset(0, 1).Value oConfigData.Add strKeySection, strKeyName, strKeyValue End If Next ---------------------------------------------------------- -------------------- Thanks in advance, Carl . |
String Function 'Like' and Special Characters
The '~' didn't work, but thanks for the help. I ended up using the Left(rKeyName.Value, 1) = "[" comparison. That worked, but I would still like to know how to get the Like function to work with special characters.
Thanks, Carl "Frank Kabel" wrote in message ... Hi try If rKeyName.Value Like "~[*" Then -----Original Message----- I'm trying to find string values that start with a bracket ("[") character. However, I know the bracket character serves a special purpose in regular expressions and string functions. For example, the first rKeyName.Value is "[paths]", but in the following code snippet; the IF statement produces an error and all combinations of apostrophes, quotes, and backslashes that I have tried don't match "[paths]". VB: ---------------------------------------------------------- -------------------- For Each rKeyName In rKeySection If rKeyName.Value Like "[*" Then strKeySection = rKeyName.Value Else strKeyName = rKeyName.Value strKeyValue = rKeyName.Offset(0, 1).Value oConfigData.Add strKeySection, strKeyName, strKeyValue End If Next ---------------------------------------------------------- -------------------- Thanks in advance, Carl . |
All times are GMT +1. The time now is 08:46 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com