1. To Regexkitlite download class library, extract will have an example package and 2 files, in fact, the use of these 2 files, added to the project.
2. Add Libicucore.dylib frameworks to the project.
3. All NSString objects can now call methods in the Regexkitlite.
NSString *email = @ "kkk@aaa.com";
[Email ismatchedbyregex:@] \\b ([a-za-z0-9%_.+\\-]+) @ ([a-za-z0-9.\\-]+?\\.[ a-za-z]{2,6}) \\b "];
Return yes, proving to be an email format, note that the regular expressions used by Regexkitlite are slightly different from those on the wiki.
SearchString = @ "http://www.example.com:8080/index.html";
regexstring = @ "\\bhttps?:/ /[a-za-z0-9\\-.] + (?::(\\d+))? (?:(?:/ [A-za-z0-9\\-._?, ' +\\&%$=~*! (): @\\\\]*) +)? ";
Nsinteger Portinteger = [[searchstring stringbymatching:regexstring capture:1l] integervalue];
NSLog (@ "Portinteger: '%ld '", (long) portinteger);
2008-10-15 08:52:52.500 host_port[8021:807] Portinteger: ' 8080′
Take the example of HTTP in string.
Here are some commonly used regular expressions (in fact, is the Regexkitlite official online, afraid of cheating with shoes) Character Description \a match a BELL, \u0007 \a match at the beginning of T He input. differs from ^ on that \a won't match after A New-line within the input. \b, outside of a [Set] Match if the current position is a word boundary. Boundaries occur at the transitions between word \w and Non-word \w, with characters combining. Also:rklunicodewordboundaries \b, within a [Set] Match a BACKSPACE, \u0008. \b Match If the current position isn't a word boundary. \cx Match a control-x character. \d Match any character with the Unicode General Category of Nd (number, Decimal Digit). \d Match Any character this is not a decimal digit. \e Match an ESCAPE, \u001b. \e terminates a \q...\e quoted sequence. \f Match a FORM FEED, \u000c. \g Match If the current position was at the end of the previous match. \ n Match a line FEED, \u000a. \n{unicode Character Name Match the named Unicode Character. \p{unicode Property Name} Match any ChaRacter with the specified Unicode property. \p{unicode Property Name} Match No character not has the specified Unicode property. \q quotes all following characters until \e. \ r Match A carriage return, \u000d. \s Match a white space character. White spaces is defined as [\t\n\f\r\p{z}]. \s Match a non-white space character. T Match a horizontal tabulation, \u0009. \uhhhh Match the character with the hex value HHHH. \uhhhhhhhh Match the character with the hex value HHHHHHHH. Exactly eight hex digits must is provided, even though the largest of the Unicode code point is \U0010FFFF. \w Match a word character. Word characters are [\p{ll}\p{lu}\p{lt}\p{lo}\p{nd}]. \w Match a non-word character. \x{h ...} Match the character with hex value HHHH. From one to six hex digits is supplied. \xhh Match the character with two digit hex value HH. \x Match a grapheme Cluster. \z Match If the current position was at the "end of" input, but before the final line terminator, if one exists. \z Match if the curRent position is in the end of input. \ Reference back. Match whatever the nth capturing group matched. n must be a number≥1 and≤total number of capture groups into the pattern. Note:octal escapes, such as \012, are not supported. [Pattern] Match any one character from the set. The Regular Expression Character Classes for A is full description of what to appear in the. . Match any character. ^ Match at the beginning's a line. $ Match at the "a line." \ quotes the following character. Characters that must is quoted to be treated as literals are *? + [() {} ^ $ | \./Operatorsoperator Description | Alternation. a| b matches either A or B. * Match zero or more. Match as many times as possible. + Match one or more times. Match as many times as possible. ? Match zero or one times. Prefer one. {n} Match exactly n times. {N,} Match at least n times. Match as many times as possible. {N,m} Match between N and M times. Match as many times as possible, but not more tHan M. *? Match zero or more times. Match as few times as possible. +? Match one or more times. Match as few times as possible. ?? Match zero or one times. Prefer zero. {n}? Match exactly n times. {N,}? Match at least n times, but no. than required for a overall pattern match. {n,m}? Match between N and M times. Match as few times as possible and but not less than N. *+ match zero or more. Match as many times as possible when the do not retry with fewer if even match overall. Possessive match. + + Match one or more times. Possessive match. ? + Match zero or one times. Possessive match. {n}+ Match exactly n times. Possessive match. {n,}+ Match at least n times. Possessive match. {n,m}+ Match between N and M times. Possessive match. (...) Capturing parentheses. Range of input that matched the parenthesized subexpression are available after the match. (?:...) non-capturing parentheses. Groups the included pattern, but does not provide capturing of matching text. SomeWhat more efficient than capturing parentheses. (? ...) Atomic-match parentheses. The parenthesized subexpression is the only one tried; If it does not leads to a overall pattern match, then the search for a match to a position before the?>. (?#...) Free-format comment (? #comment). (? = ...) Look-ahead assertion. True if the parenthesized pattern matches in the current input position, but does not advance the input position. (?! ...) Negative Look-ahead Assertion. True If the parenthesized pattern does isn't match at the current input position. does not advance the input position. (<= ...) Look-behind assertion. True if the parenthesized pattern matches text preceding the "current input position" with the last character of the match Being the input character just before the current position. Does not alter the input position. The length of possible strings matched by the look-behind pattern must is not unbounded (no * or + operators). (?<!...) Negative Look-behind AssertIon. True If the parenthesized pattern does isn't match text preceding the current input position, with the last character of the Match being the input character just before the current position. Does not alter the input position. The length of possible strings matched by the look-behind pattern must is not unbounded (no * or + operators). (? ISMWX-ISMWX: ...) Flag settings. Evaluate the parenthesized expression with the specified flags enabled or-disabled. (? ismwx-ismwx) Flag settings. Change the flag settings. Changes apply to the portion of the pattern following the setting. For example, (? i) changes to a case insensitive match. Also:regular Expression Options
Also note that the escape character Oh ~ ~ in Safari copy will be directly converted (the site is quite humane)
At the same time also provides the conversion tool, Safari test support, may download the time a bit slow, patiently waiting, links
Source: http://www.minroad.com/?p=85