match string to regular expression - Objective C

Ads
 

match string to regular expression - Objective C

How to match string value to regular expression in objective c?

View Answers

September 9, 2011 at 4:08 PM

Use NSPredicate. See the example given below...

NSString *searchString = @"loginStatus";
NSString *regexString = @"[a-z0-9_.%][email protected][a-z0-9_.%]+\\.[a-z][a-z][a-z]";
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"self matches %@", regexString];
BOOL isStringValid = [predicate evaluateWithObject:searchString];

Ads









Related Tutorials/Questions & Answers:
split string with regular expression
split string with regular expression  How to split string with regular expression in Java
Regular expression in c++{MFC}
Regular expression in c++{MFC}  Hi ALL, I want to build a regular expression in c++{MFC} which validates the URL. The regular expression must... of %5C & %2F character. How can we develop a generic Regular Expression
Advertisements
Regular expression
Regular expression  how i write a regular expression for a pattern which present in between
PHP Regular Expression
PHP regular expression allows programmer to perform various task like... strings. PHP Regular expression also allows you to validate a email, phone... chunks. There are basically two types of PHP Regular Expression. POSIX
Regular expression
Regular expression  I have the regular expression : var x=/(^\d+$)/ which allows only numbers. It does not accept character, decimals. However it accepts zero. I want an expression that takes numbers(no decimals)except zero
Regular expression
Regular expression  how i extract string Coalition of civil society organizations and CSOs from string:- CSOs : What happening in Yemen is political crisis SANA'A, May 16 (Saba)- Coalition of civil society organizations (CSOs
using regular expression
using regular expression  How can we extract string 'abc.com ' from a string http://[email protected] using regular expression of php
Regular expression
Regular expression  can some one explain how below regex works, ndmurl1=${ndmurl#${ndmurl
javascript regular expression
javascript regular expression  i need a regular expression code for JavaScript
regular expression for special characters
regular expression for special characters  How to find out regular expression for special characters
regular expression for phone number
regular expression for phone number  Hi, i need the regular expression code for phone number in PHP. Thanks.   PHP - regular expression code for phone number \+?([0-9]{2})-?([0-9]{3})-?([0-9]{6,7
Regular Expression for removing XML Tags
Regular Expression for removing XML Tags  Hi, Good Afternoon.I want a Regular expression in java which is removing the XML Tags in the specified... after applying regular expression is only "How are you".Need to remove all XML
java regular expression
java regular expression  hi i need java expression which allows all characters with minimum 2 characters and maximum 20 characters in answers field after selecting security questions
including index in java regular expression
including index in java regular expression  Hi, I am using java regular expression to merge using underscore consecutive capatalized words e.g.... from you is that is it possible using regular expression to avoid first word
What is regular expression beginning of line ?
and then replace the text using replaceAll() function of String. What is regular expression...What is regular expression beginning of line ?  Hi, I one of my Java... this will be helpful for you. http://www.roseindia.net/java/string-examples/string
URL Regular Expression for Struts Validator
URL Regular Expression for Struts Validator  I want to know how to validate a url link in struts validation.xml. Please share me the regular expression for url link validation
URL Regular Expression for Struts Validator
URL Regular Expression for Struts Validator  I want to know how to validate a url link in struts validation.xml. Please share me the regular expression for url link validation
Regular Expression Help Help HELP!!!!
Regular Expression Help Help HELP!!!!  HI all I am very new to java, but i have this problem i got a string e.g Courses['07001'].Title... did that by using this expression String regex = "Courses\[\'[^\']+\'\]\.Title
regular expression expalanation i need
your regular expression. ^ shows beginning of string...regular expression expalanation i need  hi......... here is my code... to 4. $ is used for ending the string. test() method
Phone number validation using regular expression
Phone number validation using regular expression  Explain phone number validation using regular expression in JavaScript.   phone = phone.replace(/[^0-9]/g, ''); if(phone.length != 10) { alert("not 10 digits
Java validate phone number using regular expression
Java validate phone number using regular expression In this tutorial, you will learn how to validate the phone number using regular expression. The user... { public static boolean validatePhone(String phone){ return
Evaluating a math expression given in string form
Evaluating a math expression given in string form  Evaluating a math expression given in string form
Regular Expressions
_Resetting.java.   Match string using regular expression without Case... Regular Expression This Example describes the way to retrieve the String using Regular expression.    Retrieving String
c++ new, delete, string class
c++ new, delete, string class  Write one program containing all these string exercises. Read a string from the user into a string named string1... contained in string1: Exercise 1 Good morning Create a new string named string2
C String Substring
C String Substring       In this section, you will learn how to get the substring from a string in C. You can see in the given example, a string and a method substring
C String Copy
C String Copy       In this section, you will learn how to copy the string in C. You can see in the given example, two string variables st1 and st2 are created. A string
C String to Int
C String to Int       In this section, you will learn how to convert a string represented value into an integer represented value in C. You can see in the given example that we
C String length
C String length       In this section, you will learn how to determine the length of a String in C. You can see in the given example, we have declared a string and initialize
How ro convert char into string using recursive function in c#??
How ro convert char into string using recursive function in c#??  This coding is for java...but i want this in c# How ro convert char into string using recursive function in c#?? char [] ch={'H','E','L','L','o'}; TO ans
C String Tokenizer
C String Tokenizer      ... define a string and a pointer. The expression ch = strtok (st," "...) prints the string after being tokenized. The expression ch = strtok (NULL
C String Remove Spaces
C String Remove Spaces       In this section, you will study how to remove spaces from the string. You can see in the given example, we have define the string and passed

Ads