-1
A
回答
0
我不這麼認爲。可能是你已經使你的自定義庫相同。此外,我會檢查我是否可以找到這種類型的圖書館或功能,並會讓你知道。
1
使用NSRegularExpression
來創建正則表達式對象。在OC
示例代碼:斯威夫特
[NSRegularExpression regularExpressionWithPattern:@"Your regexp pattern" options:NSRegularExpressionCaseInsensitive error:nil];
NSString *str = @"your string to match";
NSRange matchResult = [regexp rangeOfFirstMatchInString:str options:kNilOptions range:NSMakeRange(0, [str length])];
if(matchResult.length > 0) {
// NSString match with the regular expression
} else {
// NSString not match with the regular expression
}
示例代碼
let regExp = try! NSRegularExpression(pattern: "Your pattern", options: .CaseInsensitive)
let matchStr = "Your string"
let matchResult = regExp.rangeOfFirstMatchInString(matchStr, options: NSMatchingOptions(rawValue: 0), range: NSMakeRange(0, matchStr.characters.count))
if matchResult.length > 0 {
// String match with regexp
} else {
// String not match
}
相關問題
- 1. Ruby:從字符串生成新的正則表達式
- 2. 如何從簡單的正則表達式生成字符串?
- 3. 是否可以生成匹配正則表達式字符串的字符串?
- 4. 從正則表達式生成字符串數據
- 5. 從正則表達式生成部分隨機字符串
- 6. 從字符串生成正則表達式
- 7. Python基於正則表達式格式生成字符串
- 8. 正則表達式從字符串
- 9. 正則表達式從字符串
- 10. 正則表達式從字符串
- 11. 正則表達式從字符串
- 12. JS正則表達式從字符串
- 13. 正則表達式從字符串
- 14. 正則表達式從字符串
- 15. 正則表達式從字符串
- 16. 正則表達式從字符串
- 17. 正則表達式從字符串
- 18. 正則表達式從字符串
- 19. JavaScript正則表達式從字符串
- 20. 正則表達式 - 從字符串
- 21. 正則表達式從字符串
- 22. 正則表達式從字符串
- 23. 正則表達式從字符串
- 24. 正則表達式從字符串
- 25. 正則表達式從字符串
- 26. 正則表達式從字符串
- 27. Vb.net正則表達式 - 從字符串
- 28. 正則表達式從字符串
- 29. 正則表達式從字符串
- 30. 正則表達式從字符串
哪個字符串,顯示一些例子? –