nsregularexpression

regular expression

点点圈 提交于 2021-02-16 21:08:56
问题 How do I write a regular expression to get that returns only the letters and numbers without the asterisks in between ? 回答1: You could use a regex replacement here: my $var = 'RMRIV43069411**2115.82'; $var =~ s/^.*?\D(\d+(?:\.\d+)*)$/$1/g; print "$var"; // 2115.82 The idea is to capture the final number in the string, and then replace with only that captured quantity. Here is an explanation of the pattern: ^ from the start of the input .*? consume all content up until \D the first non digit

regular expression

我与影子孤独终老i 提交于 2021-02-16 21:06:41
问题 How do I write a regular expression to get that returns only the letters and numbers without the asterisks in between ? 回答1: You could use a regex replacement here: my $var = 'RMRIV43069411**2115.82'; $var =~ s/^.*?\D(\d+(?:\.\d+)*)$/$1/g; print "$var"; // 2115.82 The idea is to capture the final number in the string, and then replace with only that captured quantity. Here is an explanation of the pattern: ^ from the start of the input .*? consume all content up until \D the first non digit

regular expression

混江龙づ霸主 提交于 2021-02-16 21:04:37
问题 How do I write a regular expression to get that returns only the letters and numbers without the asterisks in between ? 回答1: You could use a regex replacement here: my $var = 'RMRIV43069411**2115.82'; $var =~ s/^.*?\D(\d+(?:\.\d+)*)$/$1/g; print "$var"; // 2115.82 The idea is to capture the final number in the string, and then replace with only that captured quantity. Here is an explanation of the pattern: ^ from the start of the input .*? consume all content up until \D the first non digit

Regular Expression to mask any string matching 10 digits only in golang

梦想的初衷 提交于 2021-01-28 11:52:59
问题 Since golang regex does not support lookaheads, I was wondering is there any way i can create a regex that will mask any string having a 10 digit number. func main() { s := "arandomsensitive information: 1234567890 this is not senstive: 1234567890000000" re := regexp.MustCompile(`\d{10}`) s = re.ReplaceAllString(s, "$1**********$2") fmt.Println(s) } Is it possible to get an output like this "arandomsensitive information: 1234****** this is not senstive: 1234567890000000" Also any regex

Unable to detect http links using Regex

回眸只為那壹抹淺笑 提交于 2020-04-18 08:41:27
问题 I am using TTTAttributedLabel to detect hyperlinks in my text so that I can make them clickable. My code does not work, and links aren't clickable. In fact, everything is clickable. I only want URL's to be clickable. here is the regex: static NSRegularExpression *websiteRegularExpression; static inline NSRegularExpression * WebsiteRegularExpression() { if (!websiteRegularExpression) { websiteRegularExpression = [[NSRegularExpression alloc] initWithPattern:@"\b(https?|ftp|file)://[-A-Z0-9+&@#/

Named capture groups in NSRegularExpression - get a range's group's name

会有一股神秘感。 提交于 2020-01-13 08:29:11
问题 Apple says that NSRegularExpression is based on the ICU Regular Expression library: https://developer.apple.com/library/ios/documentation/Foundation/Reference/NSRegularExpression_Class/ The pattern syntax currently supported is that specified by ICU. The ICU regular expressions are described at http://userguide.icu-project.org/strings/regexp. That page (on icu-project.org) claims that Named Capture Groups are now supported, using the same syntax as .NET Regular Expressions: (?<name>...) Named

NSRegularExpression separating paragraphs

陌路散爱 提交于 2020-01-05 12:02:49
问题 Consider this text: Paragraph 1: Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Paragraph 2 Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea

Objective-C, regular expression match repetition

六月ゝ 毕业季﹏ 提交于 2020-01-05 07:34:33
问题 I found a problem in regular expression to match all group repetition. This is a simple example: NSString *string = @"A1BA2BA3BC"; NSString *pattern = @"(A[^AB]+B)+C"; NSError *error = nil; NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:pattern options:0 error:&error]; NSArray *array = [regex matchesInString:string options:0 range:NSMakeRange(0, [string length])]; Returning array have one element which contains two ranges, whole input string and last captured

Objective-C, regular expression match repetition

混江龙づ霸主 提交于 2020-01-05 07:34:29
问题 I found a problem in regular expression to match all group repetition. This is a simple example: NSString *string = @"A1BA2BA3BC"; NSString *pattern = @"(A[^AB]+B)+C"; NSError *error = nil; NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:pattern options:0 error:&error]; NSArray *array = [regex matchesInString:string options:0 range:NSMakeRange(0, [string length])]; Returning array have one element which contains two ranges, whole input string and last captured

Which NSRegularExpression was found using the | operator

…衆ロ難τιáo~ 提交于 2020-01-05 04:31:50
问题 I'm currently implementing NSRegularExpressions to check for patterns inside a UITextView string in my project. The patterns check and operations are working as expected; for example: I'm trying to find the regular **bold** markdown pattern and if I find it I apply some text attributed to the range, and it works as expected. I have though came across a problem. I don't know how to run multiple patterns at once and apply different operations for each pattern found. In my UITextView delegate