You are here: Re: Yet another Regexp question « PHP Programming Language « IT news, forums, messages
Re: Yet another Regexp question

Posted by Rik on 08/23/06 18:38

HaggMan wrote:
> I'm trying to get the regular expression which matches text between
> two underscores:
> _MATCHTHIS_
>
> The problem is, I don't want to match it if the only thing in between
> the underscores are spaces or other underscores:
> _ _ _
> (this should get no match)
>
> _hello world_
> (this should match "hello world" even though there's a space because
> there's also things besides a space and underscore)
>
> Right now, I've got this:
> /_([^_]+?)_/ which does well at excluding _
>
> I've also tried this:
> /_([^_\s]+?)_/ which does well if there are NO spaces between the _'s.
> ie:
> _hello_
> (correctly matches "hello")
> _hello world_
> (does not match "hello world" as I would like)
> _ _ _
> (correctly does not match this)

/_(\s*(:?[^_\s]+\s*)+)_/

Grtz,
--
Rik Wasmus

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация