Uibot正则表达式
时间: 2023-12-12 22:36:02 浏览: 100
以下是使用UiBot中的正则表达式的例子:
1. 匹配字符串中的数字
```
sText = "abc123def456"
sPattern = "\d+"
sNew = ""
nCount = 0
result = System.Text.RegularExpressions.Regex.Replace(sText, sPattern, sNew, nCount)
Log.LogMessage(result) # 输出:123456
```
2. 匹配字符串中的邮箱地址
```
sText = "my email is abc@def.com"
sPattern = "\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"
sNew = ""
nCount = 0
result = System.Text.RegularExpressions.Regex.Replace(sText, sPattern, sNew, nCount)
Log.LogMessage(result) # 输出:my email is
```
3. 匹配字符串中的手机号码
```
sText = "my phone number is 12345678901"
Pattern = "1[3-9]\d{9}"
sNew = ""
nCount = 0
result = System.Text.RegularExpressions.Regex.Replace(sText, sPattern, sNew, nCount)
Log.LogMessage(result) # 输出:my phone number is
```
阅读全文