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

  • Home
  • SEARCH
  • 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 8466443
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T15:20:42+00:00 2026-06-10T15:20:42+00:00

I know that \s is the pattern used to match any white space in

  • 0

I know that \s is the pattern used to match any white space in a string. Now, my problem is what should be the exact regex pattern to check white space at the start or end of the string?

So, if I have a string ” hello world”, white space is at the start, so it will return true. If the string is ” hello world “, it will return true too. White space is at the start and end of the string.

I don’t need to remove white space but I just need to check if the data I got from the database has white space at the start or end.

This is my SQL query but this doesn’t really work. This only picks up data that has white space at the end:

select * from `data_table`
where `data_content` regexp '[ \f\t\v]$';

The query above give me 7 results as there are only 7 records which have white space at the end. There are 3 records that I need to fetch which have white space at the start of the string.

I tried running this SQL query:

select * from `data_table`
where `data_content` regexp '^\s' || `data_content` regexp'\s$';

It gives me 87 results. I inspected the result one by one through PHPMYADMIN and the results I got are those data that have no white space in it.

  • 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-10T15:20:44+00:00Added an answer on June 10, 2026 at 3:20 pm

    Using \s for whitespace caused the problem for me. So, I used [[:blank:]] instead and this works well:

    select data_content as     'leading_or_trailing'
    from   data_table
    where  data_content regexp '^[[:blank:]]|[[:blank:]]$';
    
    select data_content as     'leading'
    from   data_table
    where  data_content regexp '^[[:blank:]]';
    
    select data_content as     'trailing'
    from   data_table
    where  data_content regexp '[[:blank:]]$';
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am looking for a way to check if an exact string match exists
I'm wondering what is the markup pattern of DRUPAL. I know that the site
New question As suggested by Asaph in previous question: Regex to check if exact
I have a problem with one regex expression to be used so i.e. the
I know that everything we do in programming can be described as design pattern(even
To match a string with pattern like: -TEXT-someMore-String To get -TEXT- , I came
I have read in wikipedia that Decorator pattern is used for .Net and Java
Does anyone know of a neat way in java or any packages that will
I am refactoring a resource-loading function that used a traditional callback pattern to instead
What is the most popular design pattern in web app? I know that in

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.