You are here: Regex question, Text in brackets? « All PHP « IT news, forums, messages
Regex question, Text in brackets?

Posted by FFMG on 10/11/34 11:56

Hi,

I am looking for a word inside a bracket, the text is something like.
LINE1( A=10) some more text
LINE2( B=12) yet some more text
LINE3( A=13) and some more text
LINE4( B=14) and some more text

If I am looking for the value of 'A' in LINE1 then I would probably
do something like
/LINE1.*?\(.*?A=([^\)]).*?)/is

But if I am looking for a value that is not in the bracket but found in
another then it will return the value.
For example
/LINE1.*?\(.*?B=([^\)]).*?)/is

Would give me $1 = 12 even though B is in the next set of brackets.
How can I return the values found in the correct set of brackets? (and
nothing if it is not found).

Thanks

FFMG

 

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

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