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
5 answers

regex to grep string from config file in python

I have config file which contains network configurations something like given below. LISTEN=192.168.180.1 #the network which listen the traffic NETMASK=255.255.0.0 DOMAIN =test.com Need to grep the values from the config. the following is my…
Arun
  • 1,149
  • 11
  • 22
2
votes
1 answer

regular expression unicode does not work in swift

let regex1 = "(\\ud83d\\udc68)" let regex2 = "(\\ud83d[\\udc68-\\udc69])" "".capturedGroupsFull(forRegex: regex1) // returns 1 match: [(.0 "", .1 {0, 2})] "".capturedGroupsFull(forRegex: regex2) // returns nil Why is the first line returning one…
christopher.online
  • 2,614
  • 3
  • 28
  • 52
2
votes
1 answer

Regex - Match a single instance/occurrence of a character per line

I really am not getting how I can match just a single instance of both a whitespace or a dash. I am able to get some results but still unable to get the desired one. I have actually tried different configurations from regexr.com and what not but…
CodeNagi
  • 419
  • 2
  • 10
2
votes
2 answers

Why won't my SemVer NSRegularExpression run?

I'm trying to make a regex that matches a semantic version (SemVer) 2.0.0. This is my first…
Ky -
  • 30,724
  • 51
  • 192
  • 308
2
votes
1 answer

Regular Expression not working in ios11 only working fine in ios10

Requirement; All Special characters allowed excluding (`) (') () (") and Spaces using below for the same and working fine in ios 10 const UserIdRegExp = /[^`"' \\]$/g; not working in ios11 const value='anand`'; when i am doing…
Anand Neema
  • 592
  • 1
  • 3
  • 21
2
votes
1 answer

REGEX to get Vimeo & Dailymotion ID

I found two useful javascript regex but none of them seems to be working right on Swift. This works with a Youtube URL, but doesn't with Vimeo and DailyMotion. Both Vimeo & Dailymotion regex works on javascript. Thanks guys. ** EDIT WITH THE…
noisedan
  • 170
  • 2
  • 11
2
votes
1 answer

Swift 3: most performant way to check many strings with many regular expressions

I do have a list of several hundred strings and an array of 10k regular expressions. I now have to iterate over all strings and check which of the 10k regular expressions match. What's the most performant way to do this? Currently I'm doing…
swalkner
  • 16,679
  • 31
  • 123
  • 210
2
votes
1 answer

how to exclude some url from a regex match

I have 3 type payment ( online, offline, by balance) every payment type have different url so I'm using regex for match all this url : 1- order/checkout/unpaid/done 2-…
2
votes
2 answers

Username RegEx Swift

Username regex should be any string at least 8 characters long. In this string there can be @ sign, period, digits or not. I put some valid and invalid test cases below. How can I achieve this? Valid: user@user.com adminuser1 user.user@user.com…
habed
  • 201
  • 4
  • 12
2
votes
5 answers

how to obtain a regular expression for validation email address for one domain ONLY?

I am struggling with writing a regex for validating email address for only one domain. I have this expression [A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,64} But the issue is that for example hello@gmail.com.net is valid and I only want to be…
habed
  • 201
  • 4
  • 12
2
votes
1 answer

Regex - Match multiple lines that don't end with character

I have been racking my brain with a particular regex problem I currently have. I want to match values that that could span multiple lines. If the data spans multiple lines it will end with as space than an underscore " _" but there may be valid text…
NMGod
  • 1,937
  • 2
  • 12
  • 11
2
votes
1 answer

Regular Expression for Phone Number and excludes decimal numbers

I use this regex to recognize phone numbers in my app. "\\+?\\d{7,23}" But this cannot exclude decimal numbers like 3.1415926。 How to modify this regex, so that it can recognize phone numbers and do not give me decimal numbers like 3.1415926,…
wqyfavor
  • 519
  • 1
  • 4
  • 14
2
votes
2 answers

How delete all symbols from string except letters and numbers?

I am trying use next code: NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@"[\\p{L}[0-9]]+|-" options:NSRegularExpressionCaseInsensitive error:&error]; NSString *modifiedString = [regex…
Viktorianec
  • 361
  • 6
  • 22
2
votes
0 answers

NSRegularExpression gives incorrect matches for pattern

Goal : Multiple splits of the string, Each must have 50 characters. It would be really great if I can do it by proper word wrapping. It is okay to have the last split as less than 50 characters. I am using this method to split a String into…
user6375148
2
votes
2 answers

Swift: Combine two or more regular expressions

I'm using two regular expressions: var myNumbers = numbers.text?.stringByReplacingOccurrencesOfString("[^0-9]", withString: "", options: NSStringCompareOptions.RegularExpressionSearch, range:nil) myNumbers =…
user2924482
  • 8,380
  • 23
  • 89
  • 173