Questions tagged [nsregularexpression]

The NSRegularExpression class is used to represent and apply regular expressions to Unicode strings. An instance of this class is an immutable representation of a compiled regular expression pattern and various option flags. The pattern syntax currently supported is that specified by ICU. iOS 4.0+ macOS 10.7+

This class in the Apple developer library (Mac OS X, iOS) is used to represent and apply regular expressions to Unicode strings.

NOTE: This tag should be used only for questions specific to the NSRegularExpression class. Questions about regular expressions in general should be tagged .

643 questions
8
votes
2 answers

Case and diacritic insensitive matching of regex with metacharacter in Swift

I am trying to match rude words in user inputs, for example "I Hate You!" or "i.håté.Yoù" will match with "hate you" in an array of words parsed from JSON. So I need it to be case and diacritic insensitive and to treat whitespaces in the rude words…
CyrilFind
  • 319
  • 1
  • 3
  • 13
8
votes
4 answers

Named capture groups with NSRegularExpression

Does NSRegularExpression support named capture groups? It doesn't look like it from the documentation, but I wanted to check before I explore alternative solutions.
Dov
  • 14,039
  • 12
  • 71
  • 151
7
votes
5 answers

How to use regular expression in iPhone app to separate string by , (comma)

I have to read .csv file which has three columns. While parsing the .csv file, I get the string in this format Christopher Bass,\"Cry the Beloved Country Final Essay\",cbass@cgs.k12.va.us. I want to store the values of three columns in an Array, so…
Developer
  • 6,033
  • 12
  • 54
  • 90
7
votes
4 answers

Regex Persian Date validation

I want a Regular Expression for validation Persian date like 1396/4/3, 1396/12/08 or something else. in other words, I want to ensure that format of Persian Date (as String) is some thing like these valid formats…
Morteza Asadi
  • 1,593
  • 2
  • 12
  • 33
7
votes
2 answers

iOS regular expression arabic

I come from this posts Regular Expression Arabic characters and numbers only How to match arabic words with reg exp? (didn't answer my question) I've tried ^[\p{Arabic} ]+$ and received 'Parse error', reason: 'Invalid escape sequence @ pos 3: ^[\ …
Ted
  • 19,425
  • 10
  • 78
  • 99
7
votes
1 answer

Ignore escaped double quote characters swift

I am trying to validate a phone number using NSPredicate and regex. The only problem is when setting the regex Swift thinks that I am trying to escape part of it due to the backslashes. How can I get around this? My code is as follows: let…
Jacob King
  • 5,680
  • 4
  • 23
  • 43
7
votes
4 answers

How to check the validity of a GUID (or UUID) using NSRegularExpression or any other effective way in Objective-C

The method should return TRUE if the NSString is something like @"{A5B8A206-E14D-429B-BEB0-2DD0575F3BC0}" and FALSE for a NSString like @"bla bla bla" I am using something like: - (BOOL)isValidGUID { NSError *error; NSRange range =…
Goppinath
  • 9,729
  • 4
  • 20
  • 41
7
votes
2 answers

Extracting single values from a parsed NSString in objective-c

These are my sample NSStrings (parsed into an array), simplified. The single string object is parsed like "STRING1, STRING2 then DATE TIME then - A:VALUE", ex: The name of first value, first 17/04/2013 11:30:00 - A:30.0 // sometimes there is a comma…
Huxley
  • 509
  • 3
  • 9
  • 27
7
votes
2 answers

regular expression in ios to remove href links

i need some help in building a regular expression to remove href links with search terms from a long string that i then parse into a web view an example of the href string : Huntington i would like to remove…
7
votes
5 answers

regular expressions replace in iOS

I am going to need to replace a dirty string for a clean string: -(void)setTheFilter:(NSString*)filter { [filter retain]; [_theFilter release]; tmp = preg_replace(@"/[0-9]/",@"",filter); <~PSEUDO CODE> …
Ted
  • 3,533
  • 9
  • 48
  • 92
6
votes
1 answer

NSCheckingResult Range Property not set to {NSNotfound,0}?

From looking at the docs for NSTextCheckingResult I was under the impression that if no match in a NSRegularExpression search was found the range property for NSCheckingResult would be set to {NSNotFound,0} From my test below I am finding that if no…
fuzzygoat
  • 25,797
  • 45
  • 159
  • 288
6
votes
1 answer

Do any of the flavors of regex in Regex Buddy coincide with NSRegularExpression (ICU) regex?

NSRegularExpression says its flavor of regex is "ICU." I have RegexBuddy, which supports a bunch of different flavors, but none of them calls itself "ICU." But is one of them ICU under another name?
William Jockusch
  • 26,421
  • 48
  • 170
  • 299
6
votes
2 answers

Suggest # tags while typing (like Twitter) for iPhone UITextView

I'd building an app that uses hashtags, like Twitter or Tweetbot. When you're typing a message, if you type the hashtag symbol, I'd like to suggest tags that match the current one you're typing. I've already figured out how to get the UITableView to…
bryanjclark
  • 5,978
  • 2
  • 31
  • 63
6
votes
4 answers

URL Validation (Objective-C)

I am trying to validate a URL with this method: Code: - (BOOL) validateUrl: (NSString *) candidate { NSString *urlRegEx= @"((https?|ftp|gopher|telnet|file|notes|ms-help):((//)|(\\\\))+[\w\d:#@%/;$()~_?\+-=\\\.&]*)"; NSPredicate…
saleh Hosseinkahni
  • 505
  • 1
  • 6
  • 16
6
votes
1 answer

'self' used inside 'catch' block reachable from super.init call

This code is not compiling on Swift 3.3. It's showing the message: 'self' used inside 'catch' block reachable from super.init call public class MyRegex : NSRegularExpression { public init(pattern: String) { do { try…
cristianomad
  • 193
  • 1
  • 9
1
2
3
42 43