regexkitlite

How to migrate from OSSpinLock to os_unfair_lock()?

不想你离开。 提交于 2020-05-29 11:22:53
问题 As of macOS 10.12, OSSpinLock has been deprecated. The XCode error messages urge me to use os_unfair_lock_unlock() instead. As a legacy of some open source stuff I'm relying on, I'm using RegexKitLite from 2010. How can I convert the spin lock type? Simple unlocking and locking I can manage, but these comparisons are giving me headache: if(rkl_cacheSpinLock != (OSSpinLock)0) { ... } rkl_cacheSpinLock is of type os_unfair_lock and has been initialized. OSSpinLock seems to be of type int , so

How to migrate from OSSpinLock to os_unfair_lock()?

安稳与你 提交于 2020-05-29 11:21:27
问题 As of macOS 10.12, OSSpinLock has been deprecated. The XCode error messages urge me to use os_unfair_lock_unlock() instead. As a legacy of some open source stuff I'm relying on, I'm using RegexKitLite from 2010. How can I convert the spin lock type? Simple unlocking and locking I can manage, but these comparisons are giving me headache: if(rkl_cacheSpinLock != (OSSpinLock)0) { ... } rkl_cacheSpinLock is of type os_unfair_lock and has been initialized. OSSpinLock seems to be of type int , so

Finding date & time in NSString using Regex

百般思念 提交于 2020-01-03 04:47:10
问题 I want to do something similar to this question: regular expression in ruby for strings with multiple patterns But I want to do it Objective-C . Basically I want extract date and time from a string with a date and time after the @ sign. For example I have a string: Feed the Rabbits @12 , I want to extract the date and time after the @ , the problem is that the string can vary, for example it could @12:00 , @04/02/12 , @04/02/12 12:00 , @04/02/12 12:00 or just @04/02/12 . Heres my current code

Regex issue using ICU regex to find numbers not inside parentheses

北城余情 提交于 2019-12-07 18:59:34
问题 I'm trying to scan a given string for a number. The number cannot be after "v/v./vol/vol.", and cannot be inside parentheses. Here's what I have: NSString *regex = @"(?i)(?<!v|vol|vol\\.|v\\.)\\d{1,4}(?![\\(]{0}.*\\))"; NSLog(@"Result: %@", [@"test test test 4334 test test" stringByMatching:regex]); NSLog(@"Result: %@", [@"test test test(4334) test test" stringByMatching:regex]); NSLog(@"Result: %@", [@"test test test(vol.4334) test test" stringByMatching:regex]); Infuriatingly, this does not

Regex issue using ICU regex to find numbers not inside parentheses

笑着哭i 提交于 2019-12-06 11:40:56
I'm trying to scan a given string for a number. The number cannot be after "v/v./vol/vol.", and cannot be inside parentheses. Here's what I have: NSString *regex = @"(?i)(?<!v|vol|vol\\.|v\\.)\\d{1,4}(?![\\(]{0}.*\\))"; NSLog(@"Result: %@", [@"test test test 4334 test test" stringByMatching:regex]); NSLog(@"Result: %@", [@"test test test(4334) test test" stringByMatching:regex]); NSLog(@"Result: %@", [@"test test test(vol.4334) test test" stringByMatching:regex]); Infuriatingly, this does not work. My regex can be separated into four parts: (?i) - make regex case insensitive (?<!v|vol|vol\\.|v

iPhone - Reg Exp for url validity

被刻印的时光 ゝ 提交于 2019-12-06 10:11:43
问题 I have a chat view, where users can send urls to one another. In case of a url, I want to let the user press on the link and open a web view. I'm using IFTweetLabel which uses RegexKitLite. Currently the only support available is if the url starts with http/https. I want to support links without the http, for example : www.nytimes.com , and even without the "www" , nytimes.com. (and bunch of other extentions). This is the http/s prefix reg exp : @"([hH][tT][tT][pP][sS]?:\\/\\/[^ ,'\">\\]\\)]*

How do I escape special characters in an NSString using RegexKitLite?

て烟熏妆下的殇ゞ 提交于 2019-12-06 06:22:36
问题 I'm constructing a regular expression that uses strings input by the user but the strings might contain special characters such as . \ or * and I want those to be treated as literals and not interpreted by their special meanings in the regex. I've tried this: NSString *word = [input stringByReplacingOccurrencesOfRegex:@"(\\P{L})" withString:@"\\$1"]; but the non letter characters are converted to '$1' instead of being prefixed with a backslash. I've tried one and three backslashes in the

iPhone - Reg Exp for url validity

这一生的挚爱 提交于 2019-12-04 15:02:17
I have a chat view, where users can send urls to one another. In case of a url, I want to let the user press on the link and open a web view. I'm using IFTweetLabel which uses RegexKitLite. Currently the only support available is if the url starts with http/https. I want to support links without the http, for example : www.nytimes.com , and even without the "www" , nytimes.com. (and bunch of other extentions). This is the http/s prefix reg exp : @"([hH][tT][tT][pP][sS]?:\\/\\/[^ ,'\">\\]\\)]*[^\\. ,'\">\\]\\)]) Can someone tell me the other regular expressions I need to answer my other

How do I escape special characters in an NSString using RegexKitLite?

ⅰ亾dé卋堺 提交于 2019-12-04 11:44:54
I'm constructing a regular expression that uses strings input by the user but the strings might contain special characters such as . \ or * and I want those to be treated as literals and not interpreted by their special meanings in the regex. I've tried this: NSString *word = [input stringByReplacingOccurrencesOfRegex:@"(\\P{L})" withString:@"\\$1"]; but the non letter characters are converted to '$1' instead of being prefixed with a backslash. I've tried one and three backslashes in the second term but those give me an 'Unknown escape sequence' warning in XCode. How can I print a backslash

How to check if string matches a regular expression in objective-c?

五迷三道 提交于 2019-12-03 03:08:13
问题 since regular exressions are not supported in Cocoa I find RegexKitLite very usefull. But all examples extract matching strings. I just want to test if a string matches a regular expression and get a Yes or No. How can I do that? 回答1: I've used NSPredicate for that purpose: NSString *someRegexp = ...; NSPredicate *myTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", someRegexp]; if ([myTest evaluateWithObject: testString]){ //Matches } 回答2: Another way to do this, which is a bit