Remove some characters from string

I'm scraping some items of a site and get this as response:

<a href="t-1956883.html">Oh my gooood <span class="smalltext">403 readers</span></a>

Now I want to change the href from t-1956883.html to http://www.somemagicsite.com/t1956883.

This is my current RegEx that I got; t-[0-9]*.html but I don't know how I can filter out the results instead of just matching it.

Answers


Use This,

    $string = '<a href="t-1956883.html">Oh my gooood <span class="smalltext">403 readers</span></a>
';
    $pattern = '/t-(\d+).html/';
    $replacement = 'http://www.somemagicsite.com/t$1';
    echo preg_replace($pattern, $replacement, $string);

Check preg_replace in php.net


Need Your Help

Center logo in middle of navigation menu

html css html5 css3

I am looking to display my logo in the middle of my centered top navigational menu. As it stands right now, I have the logo sitting on top of it. Would it be easiest if I split the menu items into

VB.NET 2005 problems with Designer not being able to process a code line

vb.net visual-studio-2005 crystal-reports designer

I have a problem in my project with the .designer which as everyone know is autogenerated and I ahvent changed at all. One day I was working fine, I did a back up and next day boom! the project sud...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.