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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T01:23:04+00:00 2026-06-05T01:23:04+00:00

I have a web page where users can leave comments in Russian language (UTF-8),

  • 0

I have a web page where users can leave comments in Russian language (UTF-8), like this one:

Хорошо, четко , уверено!Удачи!(БОРИС)

Some users “abuse” it for fun purposes by leaving out the spaces between words

НеСпитьсяЖукуНиЗимою,НиЛетом,лучшеПитатьсяСолнечнымСветом, лучшеСидетьЗаИгорнымСтолом,иНаслаждатьсяКаждымВистом, лучшеНоситьЗолотыеОдежды,искритьсяВсегда,неТеряяНадежды,лучшеПустьДругОстаетсяБезВзятки,ведьНевозможноЖукуЖитьБезЛапки!

which results in very wide HTML-table rows, breaking my layout.

I’m trying to counter those users by trying to find comments with over 60 non-space characters and inserting a single space char after punctuation chars (like commas) – with this piece of PHP-code:

            if (preg_match('/\S{60,}/u', $about) == 1) {
                    error_log('Splitting comment: ' . $about);
                    $about = preg_replace('/(\p{P}+\s*)/u', '$1 ', $about);
                    error_log('===Result comment: ' . $about);
            }

However this doesn’t work and has at least 2 problems

  1. Every comment is being matched, even short one like at the top
  2. The \s* isn’t greedy and “comma and space” is replaced by “comma space space” for some weird reason

Here an excerpt of my log file:

[04-Jun-2012 09:50:10] Splitting comment: Хорошо, четко , уверено!Удачи!(БОРИС)
[04-Jun-2012 09:50:10] ===Result comment: Хорошо,  четко ,  уверено! Удачи!( БОРИС)

[04-Jun-2012 09:50:10] Splitting comment: НеСпитьсяЖукуНиЗимою,НиЛетом,лучшеПитатьсяСолнечнымСветом,
лучшеСидетьЗаИгорнымСтолом,иНаслаждатьсяКаждымВистом, лучшеНоситьЗолотыеОдежды,искритьсяВсегда,неТеряяНадежды,лучшеПустьДругОстаетсяБезВзятки,ведьНевозможноЖукуЖитьБезЛапки!(nusja)
[04-Jun-2012 09:50:10] ===Result comment: НеСпитьсяЖукуНиЗимою, НиЛетом, лучшеПитатьсяСолнечнымСветом,
 лучшеСидетьЗаИгорнымСтолом, иНаслаждатьсяКаждымВистом,  лучшеНоситьЗолотыеОдежды, искритьсяВсегда, неТеряяНадежды, лучшеПустьДругОстаетсяБезВзятки, ведьНевозможноЖукуЖитьБезЛапки!( nusja)

I tried doubling the backslashes – this hasn’t changed anything.

I’m using stock PHP with latest CentOS Linux 5.x and 6.x:

# php -v
PHP 5.3.3 (cli) (built: May  7 2012 17:58:11)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
  • 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-05T01:23:06+00:00Added an answer on June 5, 2026 at 1:23 am

    Try wordwrap(). It’s a built-in function and I think that it should help you.

    If you’re looking for a reg-exp solution, there’s one in the comments – look here. It’s UTF-8 safe, so it should work for your Russian site.

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

Sidebar

Related Questions

I have this web page where users can add smilies to their comments. And
I have a web page that displays comments, and users can click a 'Flag'
I have a web page on which users can upload text files (but a
I have a web page where users can see data from MongoDB on a
I have a web page where you can add new users onto the system.
I have a requirement to allow users to open word document from web page
Here is my situation. I have a web page for users to create their
I have a web page where users need to enter customer contact information. They
I have a web page that allows users to insert form input objects with
I have a small JSF web application on WAS7.0 with just one page but

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.