Search code examples
iphoneiosios5ios4

Regular expression for url in iPhone


I am using a regular expression to validate a website address. But it is not working because its format is not correct in iPhone. Its logic is almost correct. Can anyone rebuild this regular expression for me in iPhone ?

(?<http>(http:[/][/]|www.)([a-z]|[A-Z]|[0-9]|[/.]|[~])*)

Solution

  • Check out this one

    NSString *urlRegEx =
    @"(http|https)://((\\w)*|([0-9]*)|([-|_])*)+([\\.|/]((\\w)*|([0-9]*)|([-|_])*))+";