Find spaces with Regex

  • Thread starter Thread starter colinhumber
  • Start date Start date
C

colinhumber

I need to find a regular expression that will pick up spaces that are
followed by either another space or an   expression.

I have been using the expression "(?<=) (?=[ &nbsp;])" which has been
working fine, except in the example "1 space", it is picking up the
space. I know it's because it's looking for a space, &, n, b, s, p, ;
character. How to I change the regular expression to look for a space
that is followed by a space or "&nbsp;"?

I've tried grouping the &nbsp; together using (?<=) (?=[ [&nbsp;]]) but
it isn't working.

HELP!!!
 
I need to find a regular expression that will pick up spaces that are
followed by either another space or an &nbsp; expression.

I have been using the expression "(?<=) (?=[ &nbsp;])" which has been
working fine, except in the example "1 space", it is picking up the
space. I know it's because it's looking for a space, &, n, b, s, p, ;
character. How to I change the regular expression to look for a space
that is followed by a space or "&nbsp;"?

I've tried grouping the &nbsp; together using (?<=) (?=[ [&nbsp;]]) but
it isn't working.

This should work: " (?= |&nbsp;)"

The main problem with your expression are the brackets, which make no
sense at all. Characters in brackets match alternately, so "[&nbsp;]*"
would match "&nbsp;" but also "s&p;bn". The expression "[&nbsp;]" alone,
without a quantifier like the * I added would only match a single one of
the characters in the brackets.



Oliver Sturm
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Regex 1
regex help 3
C# Regex Help - should be an easy one 1
Regular Expression Matches 9
convering a space to %20 and vice versa. 2
first project 5
If function across sheets prints value of cell 4
Regex Help 1

Back
Top