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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T11:50:53+00:00 2026-05-23T11:50:53+00:00

could you help me with the regex for the following examples: lorem ipsum size

  • 0

could you help me with the regex for the following examples:

lorem ipsum size large lorem ipsum

or

lorem ipsum size m lorem ipsum

or

lorem ipsum size 39.5 lorem ipsum 

so in short I am trying to extract one word/string after the word/delimter size until the following white space. so in the above examples it would be (in order): large, m, 39.5.

Any ideas?

Quick update:
could you please include also a possibility of

size:$(size)

or

size: $(size)

or

size $(size)
  • 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-23T11:50:54+00:00Added an answer on May 23, 2026 at 11:50 am
    $strings = array(
        'lorem ipsum size large lorem ipsum',
        'lorem ipsum size m lorem ipsum',
        'lorem ipsum size 39.5 lorem ipsum ',
    );
    foreach ( $strings as $string ) {
        if ( preg_match('#\bsize\b\s+(\S+)\s#', $string, $matches) ) {
            echo "<b>Matched '{$string}':</b>\n\n";
            print_r($matches);
        }
    }
    

    Output:

    Matched 'lorem ipsum size large lorem ipsum':
    Array
    (
        [0] => size large 
        [1] => large
    )
    
    Matched 'lorem ipsum size m lorem ipsum':
    Array
    (
        [0] => size m 
        [1] => m
    )
    
    Matched 'lorem ipsum size 39.5 lorem ipsum ':
    Array
    (
        [0] => size 39.5 
        [1] => 39.5
    )
    

    Size is stored in $matches[1].

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

could someone help me with the regex pattern that i could use to match
I wonder if someone could help me figure out how to parse a string
Do you think jquery could help me get the following script work faster? Thanks!
I would like to parse a mailer to-string which could consist of the following
It would be great if someone could help me with a Regex for phone
I'm a complete novice when it comes to regex. Could someone help me convert
I'm a complete noob to regex and I need help with splitting a string.
I have the following string: $/Mycollection/Branches/Dev/New/php/MySite/src/MySite/somefolder/src/sad.php I need to create regex pattern and take
I am trying to make a regex which will match the following formats so
I'm really bad at regex and was wondering if anyone could help me with

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.