# Re: removing spaces between single characters with regual ex

**URL:** <https://www.ruby-forum.com/t/re-removing-spaces-between-single-characters-with-regual-ex/68465>\
**Category:** Ruby\
**Created:** [September 12, 2006, 9:51pm UTC](https://www.ruby-forum.com/t/re-removing-spaces-between-single-characters-with-regual-ex/68465 "2006-09-12T21:51:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![phrogz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/2acd7d/32.png) [@phrogz](https://www.ruby-forum.com/u/phrogz)\
**Post date:** [September 12, 2006, 9:51pm UTC](https://www.ruby-forum.com/t/re-removing-spaces-between-single-characters-with-regual-ex/68465/1 "2006-09-12T21:51:55Z")

</div>

From: ciapecki [[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)]

> > irb(main):006:0\> s.gsub( /\b([a-z]) (?=[a-z]\b)/i, ‘\1’ )  
> > =\> “A long cat and a quick mouse met oj simpson on the tcp stack”
> 
> this is exactly what I need.  
> Is it possible to rewrite it without using lookahead (?=subexp) ?

I don’t think so, unless you have a positive lookbehind instead.

Why don’t you want the lookahead? Are you actually using this regexp  
with a language other than Ruby?

---

<div class="post-metadata">

**Author:** ![phrogz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/2acd7d/32.png) [@phrogz](https://www.ruby-forum.com/u/phrogz)\
**Post date:** [September 12, 2006, 10:01pm UTC](https://www.ruby-forum.com/t/re-removing-spaces-between-single-characters-with-regual-ex/68465/2 "2006-09-12T22:01:56Z")

</div>

> Why don’t you want the lookahead? Are you actually using this regexp  
> with a language other than Ruby?

right. I need to write it later in oracle pl/sql, but right now wanted  
to play a little with powerful ruby 🙂  
Thanks again for your help  
chris
