Results 1 to 3 of 3

Thread: Searching the string

  1. #1

    Thread Starter
    Lively Member sridharao's Avatar
    Join Date
    Feb 2007
    Posts
    106

    Searching the string

    I want to search a string for occurrence of several characters and word in one syntax; for example I want to look for characters "http://" "<a" "<div>" "</" "htm" and other tags in the string. All in one syntax. Can anyone help me?
    Save trees, avoid plastics, say no to zoo, go veg, recycle as much, live holistic

  2. #2
    PowerPoster
    Join Date
    Sep 2003
    Location
    Edmonton, AB, Canada
    Posts
    2,629

    Re: Searching the string

    using the regular expression below with preg_match() should work fine:

    Code:
    @(<(a|div|/)|http://|htm)@i
    for example:
    PHP Code:
    $pattern '@(<(a|div|/)|http://|htm)@i';
    $str "http://davidmiles.ca";

    if(
    preg_match($pattern$str)){
      echo 
    "the string was found";
    }else{
      echo 
    "the string was not found";

    if you would like an explanation of the regular expression, please don't hesitate to ask.

  3. #3

    Thread Starter
    Lively Member sridharao's Avatar
    Join Date
    Feb 2007
    Posts
    106

    Re: Searching the string

    Thank you "David", I will take your offer. I have read a few tutorials but never really able to understand regular expressions.
    Save trees, avoid plastics, say no to zoo, go veg, recycle as much, live holistic

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width