• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 598
  • 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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