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
1 answer

Replace regex matches in attributed string with image in Objective-C

My goal is to store the information for an attributed string in Parse.com. I decided to come up with an encoding for attributed text for my images that works by replacing any string {X} in braces with the corresponding image. For example: Picture of…
2
votes
2 answers

NSRegularExpression - match multiple string

Basically, my string looks like this: @"{{attendee.prefix}} {{attendee.firstname}} {{attendee.lastname}}, fwf
lalallasgabab {{attendee.weg2g}} {{attendee.5236t2gsg}}  {{attendee.ticket_no}}…
nero
  • 64
  • 1
  • 8
2
votes
4 answers

Regular Expression for Confirm Password

My password regex is - (NSString *) getRegularExpression:(NSString *)extraWords { /* * ^$ Empty string * | Or * ^ Start of a string * [] Explicit set of characters to match * …
Chris So
  • 711
  • 1
  • 11
  • 23
2
votes
1 answer

Replace using regular expression with replacement function

In objective-c (for ios) I want to achieve the same as I can in AS3: var test:String = "Abba"; var reg:RegExp = /(a)|(b)/g; var replacement:Function = function (...args):String { var $1:String = args[1];//matched 'a' var $2:String =…
2
votes
1 answer

Objective-C regex for touching hastags

I've got a bit of code (below) which parses a uitextfield for hashtags and @-symbols whenever the text changes. It works fine with: #one #two ..but fails when the two has tags are next to each other, like this: #one#two This is my code: -…
cannyboy
  • 24,180
  • 40
  • 146
  • 252
2
votes
2 answers

NSRegularExpression get only the regex

i have a problem and i don't undestand how to do this ( after 6hours or googling) i'have a string named "filename" containt this text :"Aachen-Merzbrück EDKA\r\r\nVerkehr" i want to use regex to only get this part "Aachen-Merzbrück EDKA" but i…
Jeffrey
  • 452
  • 1
  • 9
  • 22
2
votes
1 answer

regular expression to detect opening/closing pair characters in Objective C

I am writing a program to detect markdown emphasis syntax in text. For example, the bold syntax enclosed with **, and the italic syntax enclosed with *. I have the following regex pattern: NSRegularExpression *regex; regex = [NSRegularExpression…
Jensen
  • 1,653
  • 4
  • 26
  • 42
2
votes
1 answer

How to search and trim image filenames from json using regex?

I need to trim image filenames inside json to empty values, so I'v started to try with regex. There are different image tags in json but they all end with "_url" suffix. Tried various combinations with regex but with no luck. How such regex could…
Centurion
  • 14,106
  • 31
  • 105
  • 197
2
votes
4 answers

Regular Expression iOS for Various Date Formats

I am struggling to get my head around some regular expression to match some date formats. Ideally i would like one expression too match every date format possible, i am searching a email for all dates with in the body. Formats such as: Wednesday, 6…
Neil Faulkner
  • 526
  • 1
  • 4
  • 22
2
votes
1 answer

Regex stringByReplacingMatchesInString

I'm trying to remove any non-alphanumeric character within a string. I tried the following code snippet, but it is not replacing the appropriate character. NSString *theString = @"\"day's\""; NSError *error = NULL; NSRegularExpression *regex =…
Jack120
  • 213
  • 1
  • 6
  • 21
2
votes
2 answers

UIWebView retrieve a link and navigate to it

I am adding a UIWebView to my app that should load a password protected webpage. It should then select a link from that page automatically and navigate to that page. This website changes it's links continuously so there is no way to select the URL…
2
votes
1 answer

Validating IP address by regular expression - Unknown escape sequence

I am working on an iOS project that require using regular expression to validate ipv4 address. I use following code // only support ip4 currently NSRegularExpression *regex = [NSRegularExpression …
user1193256
  • 43
  • 1
  • 6
2
votes
1 answer

Input character validation using word validation regular expression

Let's say, I have a regular expression that checks the validation of the input value as a whole. For example, it is an email input box and when user hits enter, I check it against ^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$ to see if it is a valid…
Sierra Alpha
  • 3,707
  • 4
  • 23
  • 36
2
votes
2 answers

Regex: Match tag if width or height is smaller than 100px

i would love to get rid of some tiny images in a rssfeed by matching and removing them with Apples NSRegularExpressions. should be matched for removal -> should…
HolyMac
  • 57
  • 1
  • 6
2
votes
2 answers

Use NSRegularExpression to replace each match with a result of method

I'd like to use enumerateMatchInString to find every abbreviation a call my method ConvertAbbreviation:(NSString *)abbr; to covert that abbreviation and return the full string. Can someone help me with this? I am getting exceptions when I try the…
Faz Ya
  • 1,480
  • 2
  • 15
  • 22