You are here: Regular expression help needed « PHP Programming Language « IT news, forums, messages
Regular expression help needed

Posted by Karin Jensen on 11/15/70 11:24

Hi

I am writing in PHP and trying to work with regular expressions
on records in a multilanguage database. I understand regexp basics,
but have bitten off more than I can chew here and really need help.

The problem is to do with generating all strings that match a
pattern defined in terms of brackets and slashes. Here, brackets
mean that something is optional and slashes are used to show
alternatives.

In the examples below, all the matches I need to generate are
shown below the original string.

Here are some simple brackets:
aardappel(en)
aardappel
aardappelen
homard ( la) bordelaise
homard bordelaise
homard la bordelaise

And brackets used in combination with slashes:
croquant(e)/(s)
croquant
croquante
croquants
croquantes
agrio/a/(s)
agrio
agria
agrios
agrias

Words can also be bracketed:
crale(s) (froide(s))
crale
crales
crale froide
crales froides
crale froides (even though these last
crales froide two aren't proper French)

And slashes used for whole word alternatives:
jablecn zvin/trdl
jablecn zvin
jablecn trdl
cuerpo, con/de
cuerpo, con
cuerpo, de
douillon(s)/douillen(s)
douillon
douillons
douillen
douillens

Maybe the expression would have to decide on a whole word
substitution rather than a single letter - e.g "cuerpo, con/de"
isn't "cuerpo, cde" - if the "slashed" term is more than a single
letter?

I think I can see how to generate a set of rules based on the
above, but I have no idea how to implement the logic of them using
preg functions.

Help!
And thanks in advance...

Karin

 

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

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