如何转义 Microsoft Log Parser 查询中的通配符?
How to escape wildcard characters in Microsoft Log Parser query?
如何在 logparser LIKE
条件中提供转义字符?
当前查询:
SELECT EXTRACT_TOKEN(cs-uri-stem,1,'/') AS AppPath, Count(*) AS ReqCount
FROM <MyLogFile>
WHERE AppPath LIKE '%_%'
示例数据:
+-------------+
| cs-uri-stem |
+-------------+
| 120_ABC |
| 321_XYZ |
| 11_BXY |
| ALPHA |
| BETA |
+-------------+
根据以上数据,我只想过滤掉包含下划线的行。
我尝试了 SQL 中常用的转义选项,例如 angle brackets [_]
、LIKE '%_%' ESCAPE '\' clause
,但它们没有帮助。
来自 Logparser 帮助文件:
Wildcard pattern matching characters can be used as literal characters. To use a wildcard character as a literal character, escape the wildcard character with the '\' (backslash) character.
Examples:
LIKE 'ab_d': matches the "ab_d" string (e.g. "ab_d", "AB_d")
LIKE 'a\%c%': matches all the strings that start with "a%c" (e.g. "a%cdefg", "A%c")
您的查询应如下所示:
SELECT EXTRACT_TOKEN(cs-uri-stem,1,'/') AS AppPath, Count(*) AS ReqCount
FROM <MyLogFile>
WHERE AppPath LIKE '%\_%'
如何在 logparser LIKE
条件中提供转义字符?
当前查询:
SELECT EXTRACT_TOKEN(cs-uri-stem,1,'/') AS AppPath, Count(*) AS ReqCount
FROM <MyLogFile>
WHERE AppPath LIKE '%_%'
示例数据:
+-------------+
| cs-uri-stem |
+-------------+
| 120_ABC |
| 321_XYZ |
| 11_BXY |
| ALPHA |
| BETA |
+-------------+
根据以上数据,我只想过滤掉包含下划线的行。
我尝试了 SQL 中常用的转义选项,例如 angle brackets [_]
、LIKE '%_%' ESCAPE '\' clause
,但它们没有帮助。
来自 Logparser 帮助文件:
Wildcard pattern matching characters can be used as literal characters. To use a wildcard character as a literal character, escape the wildcard character with the '\' (backslash) character.
Examples:
LIKE 'ab_d': matches the "ab_d" string (e.g. "ab_d", "AB_d")
LIKE 'a\%c%': matches all the strings that start with "a%c" (e.g. "a%cdefg", "A%c")
您的查询应如下所示:
SELECT EXTRACT_TOKEN(cs-uri-stem,1,'/') AS AppPath, Count(*) AS ReqCount
FROM <MyLogFile>
WHERE AppPath LIKE '%\_%'