Forum Moderators: open

Message Too Old, No Replies

regex parsing

         

sgcet

6:35 am on Oct 18, 2005 (gmt 0)



Hi There,

Suppose u have a textarea which contains the folowing text:

01- Introduction
0101- Les atouts du numérique
0102- Principe de l'image numérique
0103- Les 4 vies de la photo numérique
0104- Pour quelles utilisations?
0105- Le rôle de Photoshop
0106- Vue d'ensemble de Photoshop
0107- Principes de travail
02- Ouvrir un document
0201- Créer un nouveau document
0202- Ouvrir une image
0203- Importer un fichier pdf
0204- Ouvrir un format raw
0205- Réglages avancés du format raw
03- .
03- Se repérer
0301- Naviguer dans l'image
0302- Gestion de l'interface
0303- Informations et repérages
04- Numériser et imprimer en haute définition
0401- Scanner depuis Photoshop
0402- Imprimer avec Aperçu
0403- Les espaces et les profils de couleur
0404- Calibrer son matériel

This is user entered data containing lessons undera given chapter.
I want to validate this with the following rules:

(1) must start with first chapter ie 01 followed by a particular number of lessons, here 0101-0107 then chapter 02 and so on

(2)all chapters/lessons must follow the numerical order, I mean 01, 02 ,03.. for chapters and 0101,0102 etc

(3) all chapters/lessons Id must end with a "-", eg 01-, 0101-, 04- etc

(4) After that anything can come before a newline but cannot be blank

I tried using split and was able to explode the string with only numbers but cannot put away the number after the chapter or text, it also creeps in
eg:0103- Les 4 vies de la photo numérique, 4 is also added to the array. And also not able to validate the numerical order
Pls help me with this,

Thanks in Advance

Sam

fish_eye

5:47 am on Oct 25, 2005 (gmt 0)

10+ Year Member



Can you please post the expression(s) you've been using so far? I'm not exactly sure I understand your problem.