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 8631171
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T09:10:54+00:00 2026-06-12T09:10:54+00:00

I have a piece of html code like the following one: <td width=24%><b>Something</b></td> <td

  • 0

I have a piece of html code like the following one:

<td width="24%"><b>Something</b></td>
          <td width="1%"></td>
          <td width="46%" align="center">
           <p><b>
    needed
  value</b></p>
          </td>
          <td width="28%" align="center">
            &nbsp;</td>
        </tr>

What is a good regex pattern to extract the first text node (not tags but the text inside) after the word Something I mean I want to extract

     needed
  value

and nothing more.

I cant figure out a working regex pattern in php.

EDIT:
I am not parsing whole html document but few lines of it so all I want is to do it using Regex and no HTML parsers.

  • 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-06-12T09:10:55+00:00Added an answer on June 12, 2026 at 9:10 am

    Ignoring potential issues parsing HTML with regex, the following pattern should match your example code:

    Something(?:(?:<[^>]+>)|\s)*([\w\s*]+)
    

    This will match Something, followed by any list of HTML tags (or whitespace) and match the very next block of text, \w (including whitespace).

    You can use this in PHP’s preg_match() method like this:

    if (preg_match('/Something(?:(?:<[^>]+>)|\s)*([\w\s*]+)/', $inputString, $match)) {
        $matchedValue = $match[1];
        // do whatever you need
    }
    

    Regex Explained:

    Something         # has to start with 'Something'
    (?:               # non-matching group
        (?:           # non-matching group
            <[^>]+>   # any HTML tags, <...>
        )
        | \s          # OR whitespace
    )*                # this group can match 0+ times
    (
        [\w\s*]+      # any non-HTML words (with/without whitespace)
    )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using jQuery with rails and have the following piece of code $('#related').html(<%= render
I have the following piece of code which play the flv file, <embed align=middle
I have HTML code like this: <tr> <td align=left valign=bottom class=leftfooter><a href=#>Customer Support</a> <a
I have the following piece of HTML code: <span class=ui-icon ui-icon-triangle-1-s></span> <span class=route-line>4</span> <span
I have the following piece of code which I'd like to optimize using Cython:
I have this piece of HTML code: <tr class=AttCardFooter onMouseOver=this.style.backgroundColor='#E1EAFE' onMouseOut=this.style.backgroundColor='Transparent'>...etc etc.. new lines
I have this simple piece of HTML code: <div> <input type=file name=english-file /> </div>
I have such html piece of code: <ul class=myClass> <li><a href=url1.html>first link</a></li> <li><a href=url2.html>second
I have a piece of code VERY similar to this one http://java.sun.com/developer/onlineTraining/JavaMail/contents.html#JavaMailFetching I the
I have this piece of code: <li class=selected><a href=/AmIACandidate.html>Am I a Candidate?</a></li> I need

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.