• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 604
  • Last Modified:

regular expression space separator

Hello -

What is the regular expression separator that represents a 'white space' or blank space' between two words in a string?

For example, in the string 'PO#1234 History', What could I use as a space separator to detect the blank space between '4' and 'History'

thanks!
0
DTwined
Asked:
DTwined
  • 13
  • 9
1 Solution
 
Terry WoodsIT GuruCommented:
\s+ matches one or more spaces (or tabs, or newlines)
0
 
Terry WoodsIT GuruCommented:
Depending on the regex engine you're working with, it may also be helpful to use \b which matches a word boundary, for example:
\bblah\b
from string:
"in this case blahdeblah won't match, but blah will"
0
 
DTwinedAuthor Commented:

Are there any other options?
0
Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

 
Terry WoodsIT GuruCommented:
You can also use just a space character, or a subset of your choice of characters eg just spaces and tabs, but not newlines: [ \t]+
0
 
Terry WoodsIT GuruCommented:
Do you have any examples that you're having trouble with?
0
 
DTwinedAuthor Commented:

What is an example of a space character?
0
 
Terry WoodsIT GuruCommented:
There are space characters between these words. Is that what you mean?
0
 
DTwinedAuthor Commented:

No, unfortunately it's a crappy UI where  I need to enter in a separator to parse a string. I can't seem to find a separator for white space that will work correctly.
0
 
Terry WoodsIT GuruCommented:
Can you explain which language or tool you're using?
0
 
DTwinedAuthor Commented:
Yes Terry. Like this string, 'PO#1234 History'.
I need to separate  'PO#1234' and 'History'.
0
 
DTwinedAuthor Commented:

It's an internal tool with no documentation, unfortunately.
0
 
Terry WoodsIT GuruCommented:
Does the tool have its own interface for entering the separator, or is it done via a command line (linux, DOS, etc)?
0
 
DTwinedAuthor Commented:

It has its own interface for entering the separator.
0
 
Terry WoodsIT GuruCommented:
Would putting quotes around it help? ie " "
0
 
Terry WoodsIT GuruCommented:
Do you know what framework or language the tool was build with?
0
 
DTwinedAuthor Commented:

I'm betting it's Linux or Unix.
0
 
Terry WoodsIT GuruCommented:
You could also try:
' '
or
\
(There's a space character after the \ character)
0
 
Terry WoodsIT GuruCommented:
Or even:
\\
(There's a space character after the \ characters)
0
 
Terry WoodsIT GuruCommented:
Or (a long shot):
'\ '
or
'\\ '
0
 
DTwinedAuthor Commented:
So it would be like this (quotes used to show space), '\ ' or '\\ '?
0
 
Terry WoodsIT GuruCommented:
I'd try it with and without the quotes
0
 
DTwinedAuthor Commented:

Definitely. I'll give it a try first thing in the morning. Thanks.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

  • 13
  • 9
Tackle projects and never again get stuck behind a technical roadblock.
Join Now