Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7661401
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T13:35:37+00:00 2026-05-31T13:35:37+00:00

I’m trying to strip the numeric and punctuations from a string leaving only alpha

  • 0

I’m trying to strip the numeric and punctuations from a string leaving only alpha characters in SIMPLE HTML DOM, with no success I’ve tried multiple approaches and just can’t get it!

Example string: The Amazing Retard (2012) #1
Output string: The Amazing Retard

I understand it’s for an undefined method and I’ve looked at multiple pages for this, however I’m brain farting for how to include the method. Any help would be appreciated. The error that I get is

Fatal error: Call to undefined method simple_html_dom_node::preg_replace() in /home/**/public_html/wp-content/themes/*/***.php on line 123

The code is as follows:

<?php

function scraping_comic()
{
    // create HTML DOM
    $html = file_get_html('http://page-to-scrape.com');

    // get block
    foreach($html->find('li.browse_result') as $article)
    {
        // get title
        $item['title'] = trim($article->find('h4', 0)->find('span',0)->outertext);
        // get title url
        $item['title_url'] = trim($article->find('h4', 0)->find('a.grid-hidden',0)->href);
        // get image
        $item['image_url'] = trim($article->find('img.main_thumb',0)->src);
        // get details
        $item['details'] = trim($article->find('p.browse_result_description_release', 0)->plaintext);
        // get sale info
        $item['on_sale'] = trim($article->find('.browse_comics_release_dates', 0)->plaintext);
        // strip numbers and punctuations
        $item['title2'] = trim($article->find('h4',0)->find('span',0)->preg_replace("/[^A-Za-z]/","",$item['title2'], 0)->plaintext);

        $ret[] = $item;

    }

    // clean up memory
    $html->clear();
    unset($html);

    return $ret;
}
// -----------------------------------------------------------------------------


$ret = scraping_comic();

if ( ! empty($ret))
{
    $scrape = 'http://the-domain.com';


    foreach($ret as $v)
    {

        echo '<p>'.$v['title2'].'</p>';
        echo '<p><a href="'.$scrape.$v['title_url'].'">'.$v['title'].'</a></p>';
        echo '<p><img src="'.$v['image_url'].'"></p>';
        echo '<p>'.$v['details'].'</p>';
        echo '<p> '.$v['on_sale'].'</p>';
    }
}
else { echo 'Could not scrape site!'; }
?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T13:35:37+00:00Added an answer on May 31, 2026 at 1:35 pm

    preg_replace is a php function, not a member of the simple_html_dom_node class. call it like this:

    $matches = preg_replace ($pattern, $replacement, mixed $subject);
    

    http://php.net/manual/en/function.preg-replace.php

    it looks like your $pattern and replacement are OK; you’ll just pass in as the $subject the input you’re trying to change.

    for example, this might be what you’re trying to achieve:

    $item['title2'] = 
      trim(preg_replace("/[^A-Za-z]/","",$article->find('h4',0)->find('span',0));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a text area in my form which accepts all possible characters from
Does anyone know how can I replace this 2 symbol below from the string
i got an object with contents of html markup in it, for example: string
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.