473,378 Members | 1,375 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Find spaces with Regex

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!!!

Nov 17 '05 #1
2 2356
co*********@gmail.com wrote:
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
--
omnibus ex nihilo ducendis sufficit unum
Spaces inserted to prevent google email destruction:
MSN oliver @ sturmnet.org Jabber sturm @ amessage.de
ICQ 27142619 http://www.sturmnet.org/blog
Nov 17 '05 #2
JP
Try " (?= |&nbsp;)"

Hope this helps
Cheers,
JP
<co*********@gmail.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
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.

HELP!!!

Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: JackRazz | last post by:
I'm trying to use Visual Studio's Find/Replace to match VB declarations. This RegEx works fine in Regulator: ...
5
by: Christine | last post by:
I have a text file that appears to be delimited by multiple spaces. The split function will only work with one space if I am correct. Is there some way to split this file into an array without...
10
by: John A Grandy | last post by:
What's the proper way to write a validation regex so that all leading and trailing spaces are trimmed before evaluation ? Thanks.
3
by: Luis Esteban Valencia | last post by:
hello quite a simple one if you understand regular expressions vbscript and ..net, probably quite hard if you don't i have a single line input which offers classic search functionality, so if...
2
by: Craig Buchanan | last post by:
I have a HTML fragment that looks like this: <tr> <td valign="top" nowrap><span class="textBold">Property ID: </span></td> <td valign="top" nowrap colspan="4"...
14
by: inpuarg | last post by:
I want to find a & character using Regex. But not && How can i manage this in c# Quickfind window ? -------------------------------------------------- ne kadar yaşarsan yaşa sevdiğin kadardır...
4
by: Trev | last post by:
Hi everyone, I'm having some problems using Regex; I have a long string that is delimetered in a random fashion by a combination of spaces and \n's for newlines. I have five possiblities: //...
9
by: Salve =?iso-8859-1?Q?H=E5kedal?= | last post by:
What is the best regular expression for finding urls in plain text files? (By urls I mean http://www.something.com, but also www.something.com, or salve@somewhere.com) Salve
3
by: bstjean | last post by:
Hi everyone, I am trying to find an efficient way to perform a special query. Let me explain what I want. Let's say we are looking for all description that match "this is the target". In...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.