Archive for the ‘Regexps’ Category

Regular expression used to validate URLs

Sometimes you need to extract some data from text files. E-mails, passwords, just some simple tags… no matter what it is, your best choice to do this is to use regular expressions. I will show you a PHP script that will extract all valid e-mails from a text file. <? $fs=fopen(“best.txt”, “r”); $f3=fopen(“clean.txt”, “a”); while(!feof($fs)) [...]

It is often necessary to extract text from a variable that contains HTML or XML code. I’ve created a simple regular expression that will help you to extract all text between certain tags into an array. It is a PHP solution, though regular expression is compatible with other programming languages. preg_match_all(“/<tag>(.*?)<\/tag>/”, $source, $results); This construsion [...]

There is a common practice to use outgoing links from your site to track visitor activity. For example, your site is www.site.com, and external links look like www.site.com/out.php?url=http://anothersite.com . It is OK for counters and traffic tracking, but may be used for an uncommon way. It this sample you may replace http://anothersite.com with any other [...]

Earn money from your website/blog by, selling text links, banner ads - Advertisers can, buy links, from your blog for SEO. Get paid through PayPal