Re: Find spaces with Regex
- From: Oliver Sturm <oliver@xxxxxxxxxxxx>
- Date: Wed, 24 Aug 2005 18:39:33 +0100
colinhumber@xxxxxxxxx wrote:
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 "(?<=) (?=[ ])" 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 " "?
I've tried grouping the together using (?<=) (?=[ [ ]]) but it isn't working.
This should work: " (?= | )"
The main problem with your expression are the brackets, which make no sense at all. Characters in brackets match alternately, so "[ ]*" would match " " but also "s&p;bn". The expression "[ ]" 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 .
- References:
- Find spaces with Regex
- From: colinhumber
- Find spaces with Regex
- Prev by Date: RE: Control Question
- Next by Date: Re: Visibility/Access of Class Members
- Previous by thread: Find spaces with Regex
- Next by thread: Re: Find spaces with Regex
- Index(es):
Relevant Pages
|