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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:06:49+00:00 2026-05-27T06:06:49+00:00

I need to enclose every single word that is at least 2 chars in

  • 0

I need to enclose every single word that is at least 2 chars in length, in a string between a span tag. All question marks, punctuation, etc, should be left outside the spans (they must only hold a-z and also special characters as ñ,á,é, etc).

So, this:

Prenda de vestir que se ajusta? A la cintura y llega generalmente hasta el pie.

Should be this:

<a href=http://example.com/prenda>Prenda</a> <a href=http://example.com/de>de</a> <a href=http://example.com/vestir>vestir</a> <a href=http://example.com/que>que</a> 
<a href=http://example.com/se>se</a> <a href=http://example.com/ajusta>ajusta</a>? A <a href=http://example.com/la>la</a> 
<a href=http://example.com/cintura>cintura</a> y <a href=http://example.com/llega>llega</a> 
<a href=http://example.com/generalmente>generalmente</a> <a href=http://example.com/hasta>hasta</a> <a href=http://example.com/el>el</a> <a href=http://example.com/pie>pie</a>.

Any ideas? Thanks!

  • 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-27T06:06:50+00:00Added an answer on May 27, 2026 at 6:06 am

    Use this:

    $result = preg_replace('/\b[\p{L}\p{M}]{2,}\b/u', '<a href=http://example.com/$0>$0</a>', $subject);
    

    All letters, all accents.

    Why:

    "
    \b              # Assert position at a word boundary
    [\p{L}\p{M}]    # Match a single character present in the list below
                    # A character with the Unicode property “letter” (any kind of letter from any language)
                    # A character with the Unicode property “mark” (a character intended to be combined with another character (e.g. accents, umlauts, enclosing boxes, etc.))
       {2,}         # Between 2 and unlimited times, as many times as possible, giving back as needed (greedy)
    \b              # Assert position at a word boundary
    "
    

    Edit:

    $result = preg_replace_callback(
            '/\b[\p{L}\p{M}]{2,}\b/u',
            create_function(
                '$matches',
                'return <a href=http://example.com/strtolower($matches[0])>$matches[0]</a>;'
            ),
            $subject
    );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to apply a class to the <li> tag that encloses an anchor
I have a C++ project with hundreds of files, and I need to enclose
When inserting a row in mysql database, string values need to be enclosed in
Need help with a query that I wrote: I have three tables Company id
I want to remove rectangles etc that enclose text in a screenshot image, so
I need to enclose special markups for the printer in the PDF build process.
I ran a data copy function in Toad that disabled all constraints and then
Do I always need to enclose the saveOrUpdate or delete on Session in DAOs
I need to perform my script (a search) on all the files of a
I have a string in which I need to add a '\' in front

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.