473,836 Members | 1,540 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2374
co*********@gma il.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*********@gm ail.com> wrote in message
news:11******** **************@ o13g2000cwo.goo glegroups.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
2072
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: ^\s*(Public|Friend|Protected|Private)*\s*(Shared|Overrides)*\s*(Sub|Function|Property )+ But when I try it in Visual Studio's find (with regular expressions turned on) it doesn't work. Are there any known problems with VS find or is there something wrong with the above expression? I'm new to them, so the second question...
5
22945
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 getting the extra spaces?
10
6415
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
2150
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 someone puts something in quotes i.e "A Gibbon" i want to extract that prior to using the rest of the string what i need is a regex string that'll turn a postback string eg "A Gibbon" "A Baboon" "George Bush" doris day into a csv array
2
6063
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" bgcolor="#F0F0F0"><b>&nbsp;01-068-24-64-1024</b></td> </tr> I am trying to extract the '' part of it.
14
2053
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 ömrün :( --------------------------------------------------
4
2326
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: // Character can be a-zA-Z0-9 plus any non-alphanumeric character (. , \ etc.) // five possibilities: // 1: Characters \nCharacters -Characters Characters // 2: Characters\n Characters -Characters Characters
9
5102
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
4834
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 fact, I want to find records that match those 4 words in this sequence disregarding the number of spaces (I mean spaces, tabs, Cr, Lf, etc) between them.
0
9664
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10539
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9367
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7782
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6976
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5645
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4446
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4006
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3108
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.