Jump to content

Search the Community

Showing results for tags 'regular expression'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • W3Schools
    • General
    • Suggestions
    • Critiques
  • HTML Forums
    • CSS
  • Browser Scripting
    • JavaScript
    • VBScript
  • Server Scripting
    • Web Servers
    • Version Control
    • SQL
    • ASP
    • PHP
    • .NET
    • ColdFusion
    • Java/JSP/J2EE
    • CGI
  • XML Forums
    • XML
    • Schema
    • Web Services
  • Multimedia
    • Multimedia
    • FLASH

Find results in...

Find results that contain...

Date Created

  • Start


Last Updated

  • Start


Filter by number of...


  • Start





Website URL








Found 3 results

  1. Hi,I had a job interview and they asked me about regular expression, I knew most most of the question. However they asked how can I define regular expression that will accept every string that contain equal number of the letter 'a' and 'b', regardless of the other chars.I mean string like:aaabbb (3 - 'a' , a - 'b')afffhgflhgfladflgkdflbdfdsfdsb (2 - 'a', 2 - 'b')avvvbbdda (2 - 'a', 2 - 'b') I told them I know how to create function that will just count the number of 'a' and 'b' and then equate them.but my question is, can I solve it with regular expression and how?
  2. i found this function in snipplr which grab a div with certain attribute but i tried to use it ,but didn't work, is there a something wrong in my way of using http://snipplr.com/view.php?codeview&id=20987 function get_tag( $attr, $value, $xml, $tag=null ) { if( is_null($tag) ) $tag = '\w+'; else $tag = preg_quote($tag); $attr = preg_quote($attr); $value = preg_quote($value); $tag_regex = "/<(".$tag.")[^>]*$attr\s*=\s*". "(['\"])$value\\2[^>]*>(.*?)<\/\\1>/" preg_match_all($tag_regex, $xml, $matches, PREG_PATTERN_ORDER); return $matches[3];} i made a change on it to use it for a url like this function get_tag( $attr, $value, $page, $tag=null ) { if( is_null($tag) ) $tag = '\w+'; else $tag = preg_quote($tag); $attr = preg_quote($attr); $value = preg_quote($value); $tag_regex = "/<(".$tag.")[^>]*$attr\s*=\s*". "(['\"])$value\\2[^>]*>(.*?)<\/\\1>/";$page = file_get_contents($page); preg_match_all($tag_regex, $page, $matches, PREG_PATTERN_ORDER); return $matches[3];}get_tag("class","weather","http://www.masrawy.com","div"); any help to know how to use it correctly?
  3. I am trying to clean up some text that has some white space that I can't seem to get rid of. I have tried replacing \s, \t,\n, \r, \r\n etc. and that strips out most of the new lines but not all. When I look at in a text editor such as TextWrangler, I am seeing an upside down question mark where these spaces are. I thought instead of trying to match something and then deleting that I could try to delete everything but what matched. I don't know how to do this with regular expressions. If anybody had a pattern and a replacement that would work, I would appreciate it. Thanks - Dave.
  • Create New...