Parse Hyperlink

$line = '<a href="/users/adam">Edit profile</a>';
$converted_line = preg_replace('/<a[^>]*?href=['"](.*?)['"][^>]*?>(.*?)</a>/si','<a href="$1" target="_blank">$2</a>',$line);
echo $converted_line;

Alpha or Numeric

is_numeric($var) will check to see if it's numbers
preg_match('%^[A-Za-z]+$%', $var) will check to see if it's letters
preg_match('%^[A-Za-z0-9]+$%', $var) will check to see if it's alphanumeric

Hyperlink Regex

var text = "";
var reg:RegExp=/(b(https?|ftp|file)://[-A-Z0-9+&@#/%?=~_|!:,.;]*[-A-Z0-9+&@#/%=~_|])/ig;
trace(text.replace(reg,"<a href="$&">$&</a>"));

Change url to html link


$str = 'My post with links in it';
preg_replace('!((?:www|http://)[^r ]+)!', '<a href="1">1</a>', $str);


//Here is another method
function addhttp($url) {     if (!preg_match("~^(?:f|ht)tps?://~i", $url)) {         $url = "http://" . $url;     }     return $url; }

Find and Replace

<script type="text/javascript">

var testString = 'This is the subject of my experiment';

//A simple find and replace statement
var simpleFind = 'experiment';
var simpleReplacement = 'simple find and replace';

//Using a regular expression for more advanced find and replace
var regexFind = /experiment/;
var regexReplacement = 'Regex';

document.write('Original: ' + testString + '<br>');
document.write('String replace: ' + testString.replace(simpleFind,simpleReplacement) + '<br>');
document.write('Regex replace: ' + testString.replace(regexFind,regexReplacement));