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 .

722 questions
2
votes
2 answers

How can I use Xcode's `Find and Replace` on Multiline blocks of text

I have a large file with hundreds of blocks of text (parts of C++ method calls) that resemble the Current block below and I wish to use Xcode’s Regular Expression replacement to change each one to resemble the Desired block below, capturing values…
Dave Chambers
  • 2,483
  • 2
  • 32
  • 55
2
votes
1 answer

NSRegularExpression class in Xamarin

Can any one suggest me how to use NSRegularExpression class in Xamarin iOS. I am not able to use this in Xamarin Studio, Looking for an equivalent method for the below one NSArray* matches = [[NSRegularExpression…
Gobi M
  • 3,243
  • 5
  • 32
  • 47
2
votes
1 answer

How to exclude "+" from being treated as special character in NSRegularExpression?

I have a following userName: iphone6s_taylor and iphone6+_taylor. to find them in text I have created following regular expression: let regex = "\\B@\(userName)\\b" But within the following text: let text = "@iphone6s_taylor @iphone6+_taylor…
Bartłomiej Semańczyk
  • 59,234
  • 49
  • 233
  • 358
2
votes
1 answer

Replacing html tag with null in XML string

I want to replace " + "
anonymox
  • 419
  • 1
  • 9
  • 32
2
votes
2 answers

Replace text with multiple Regular Expressions on iOS

I'm pretty new to using regex in iOS, and I'm experimenting with it. I'm struggling to find a solution to the problem I have. I apologize in advance if this has been answered before or I'm just missing something really obvious and/or using the wrong…
Ac128
  • 33
  • 3
2
votes
1 answer

NSRegularExpression for hashtags and mentions with special characters?

I'm using the following regex expression to detect hashtags and mentions in my app. NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@"(#|@)(\\w+)" options:NSRegularExpressionCaseInsensitive error:&error]; However…
Josh
  • 254
  • 3
  • 19
2
votes
2 answers

Validation using Regular Expressions in iOS

I'm implementing validation for username field using Regular Expression(Regex) in iOS. I don't want username to start with the word "guest". I tried below code but it's not working. [txtUserName addRegx:@"^(guest)" withMsg:@"Username Can't start…
Mughees Musaddiq
  • 1,060
  • 1
  • 10
  • 27
2
votes
1 answer

Cocoa Error 2048 on NSRegularExpression Creation

I am trying to create regular expression from the following: #define RegEX_1_UPPER_1_SPECIAL @"((?=.*[A-Z])(?=.*[$@!%*?&-+_()]).{8,})" NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern: RegEX_1_UPPER_1_SPECIAL options:0…
itechnician
  • 1,645
  • 1
  • 14
  • 24
2
votes
2 answers

NSRegularExpression Returns Invalid Range

When I run the following code in a Playground, I get an invalid range as a result: import Cocoa var error: NSError? var captureGroups: [String] = [] var input = "http://www.google.com" var pattern =…
2
votes
3 answers

Swift 2.0: NSRangeException, Range or index out of bounds

Context: I come from 15-20 years of JavaScript, Ruby and (modern) PHP. I've been poking at Swift over the last year, and I'm brand-new to Cocoa. Here's a simplified test case that I'm running in Xcode 7.0 β2: #! /usr/bin/env swift import…
Ryan Parman
  • 6,855
  • 1
  • 29
  • 43
2
votes
1 answer

Extract text between two markers with Regular Expression

Simple regex question. I have a string on the following format: [page] Some text with multi line. [page/] [page] Another text with multi line. [page/] [page] Third text with multi line. [page/] What is the regular expression to extract the text…
Almudhafar
  • 887
  • 1
  • 12
  • 26
2
votes
1 answer

Possible bug in NSRegularExpression (optional atom)…?

As part of a web service response, I'm having to extract date strings that so far have taken the either of these formats: 06 Mar 2015-10:24 EST 06 Mar 2015-10:24 (I've got no control over the service itself; there's a whole assortment of…
RiqueW
  • 212
  • 1
  • 12
2
votes
1 answer

NSRegularExpression with french character

why pattern [A-Z][A-z]* return Ve for French word Vénus using NSRegularExpression .I want to match camel word,but this word is strange
Tony Lee
  • 31
  • 2
2
votes
0 answers

Parse Movie File Name With NSRegularExpression

how i can parse a string of a movie file name like this: Tokarev.2014.iTA.ENG.1080p.Bluray.x264-NHD.mkv with NSRegularExpression to get the title name, the year and the quality of the movie? For example, the result should be: Name: Tokarev Year:…
Piero
  • 9,173
  • 18
  • 90
  • 160
2
votes
2 answers

Using NSRegularExpression to create custom NSDataDetector Type

I'm trying to create custom data detectors for content in a UITextView. I'd like to be able to do something like this: tv.dataDetectorTypes = UIDataDetectorTypeAll; but instead of UIDataDetectorTypeAll, I want to use my custom UIDataDetector based…
4m1r
  • 12,234
  • 9
  • 46
  • 58