Search Results

Search found 5 results on 1 pages for 'nsregularexpression'.

Page 1/1 | 1 

  • NSRegularExpression for stripping HTML Tag

    - by Prazi
    I am developing a ebook reader app. I have the .ePUB file for the entire ebook where in each topic of the ebook is a html file. I want to implement the search functionality in the app. I am using NSRegularExpression class for searching. Please consider the following html code: <temp> I am temp in tempo with temptation </temp> Say for example in the above html code I just want to search for the word temp. Now in above code temp is appearing 5 times - <temp> </temp> temp tempo temptation. I am looking for a regular expression where I can only extract the whole word "temp". I don't want to consider the word temp in the html tags <temp> </temp>. I also don't want the word tempo and temptation to be considered. Thanks in advance

    Read the article

  • xml regular expression/regex OR operator

    - by Naz Haque
    Hi am trying to use a regeX to read through my document to identify currency types whether they're $,£ or a €. The regex I've created doesn't seem to work, somebody please advise me what it should be. I'd really appreciate the help: The regEX I've created ("\$|£|€]")is in a simpleType within my XSD file used for validating a document. The code is show after the colon, please note to display on stackoverflow I've had to remove the open/close tags (<): xs:simpleType name="currencyType" xs:restriction base="utf8-string" xs:length value="1" / xs:pattern value="[\$|£|€]"/ /xs:restriction /xs:simpleType

    Read the article

  • Regular Expression not disappearing

    - by user2439019
    I have 3 phone fields and any one is required. SO i had a custom validation class to make any one of them is required. And i am calling those class as follows [RegularExpression(@"^\(?([0-9]{3})\)?. ]?([0-9]{3})[-. ]?([0-9]{4})$", ErrorMessage = "Entered phone format is not valid. <br/> 10 digits are required.<br/> No spaces between digits. <br/> Numbers only.")] [AtLeastOneRequired("PhoneHome", "PhoneMobile", "PhoneOffice", ErrorMessage = "Please provide either of PhoneHome or PhoneMobile or phoneOffice. ")] public string PhoneHome { get; set; } [StringLength(11, MinimumLength = 10)] [RegularExpression(@"^\(?([0-9]{3})\)?[-. ]?([0-9]{3})[-. ]?([0-9]{4})$", ErrorMessage = "Entered phone format is not valid. <br/> 10 digits are required.<br/> No spaces between digits. <br/> Numbers only.")] [Display(Name = "Prompt_PhoneOffice", ResourceType = typeof(ResContactItems))] public string PhoneOffice { get; set; } [StringLength(11, MinimumLength = 10)] [RegularExpression(@"^\(?([0-9]{3})\)?[-. ]?([0-9]{3})[-. ]?([0-9]{4})$", ErrorMessage = "Entered phone format is not valid. <br/> 10 digits are required.<br/> No spaces between digits. <br/> Numbers only.")] [Display(Name = "Prompt_PhoneMobile", ResourceType = typeof(ResContactItems))] public string PhoneMobile { get; set; } The problem is with only "PhoneHome " field , if i enter incorrect format, it will display error message based ont he regular expression given .But the regular expression message is not disappearing wwhen we enter the correct format too.It will disappear only in f the field is empty.Other two fields are showing properly. Is this due to the custom class i am calling.? Please help me to sort out this issue Thanks, Vidya

    Read the article

  • Search pattern in string using regex in obj-c

    - by manileo86
    I'm working on a string pattern match algorithm. I use NSRegularExpression for finding the matches. For ex: I've to find all words starting with '#' in a string.. Currently I use the following regex function: static NSRegularExpression *_searchTagRegularExpression; static inline NSRegularExpression * SearchTagRegularExpression() { if (!_searchTagRegularExpression) { _searchTagRegularExpression = [[NSRegularExpression alloc] initWithPattern:@"(?<!\\w)#([\\w\\._-]+)? options:NSRegularExpressionCaseInsensitive error:nil]; } return _searchTagRegularExpression; } and I use it as below: NSRegularExpression *regexp = SearchTagRegularExpression(); [regexp enumerateMatchesInString:searchString options:0 range:stringRange usingBlock:^(NSTextCheckingResult *result, NSMatchingFlags flags, BOOL *stop) { // comes here for every match with range }]; This works properly. But i just want to know if this is the best way. suggest if there's any better alternative...

    Read the article

  • Regexp in iOS to find comments

    - by SteveDolphin23
    I am trying to find and process 'java-style' comments within a string in objective-C. I have a few regex snippets which almost work but I am stuck on one hurdle: different options seem to make the different styles work. For example, I am using this to match: NSArray* matches = [[NSRegularExpression regularExpressionWithPattern:expression options:NSRegularExpressionAnchorsMatchLines error:nil] matchesInString:string options:0 range:searchRange]; The options here allow me successfully find and process single line comments (//) but not multiline (/* */), if I change the option to NSRegularExpressionDotMatchesLineSeparators then I can make multiline work fine but I can't find the 'end' of a single line comment. I suppose really I need dot-matches-line-separators but I need a better way of finding the end of a single line comment? The regexp I have so far are: @"/\\*.*?\\*/" @"//.*$" it's clear to see if dot matches a line separator then the second one (single line) never 'finishes' but how do I fix this? I found some suggestions for single line that were more like: @"(\/\/[^"\n\r]*(?:"[^"\n\r]*"[^"\n\r]*)*[\r\n])" But that doesn't' seem to work at all! Thanks in advance for any pointers.

    Read the article

1