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

sh.exe no such file or directory Python, GitBash

python git virtualenv virtualenvwrapper

I trying to setup virtualenvwrapper in GitBash (Windows 7), but get an error message "sh.exe"no such file or directory.

when a quartz job fires, is it a new job class instance?

java quartz-scheduler spring-3 job-scheduling

I am very new to Quartz and I have some doubts about the jobs lifecycle.