In a twist with regular expressions!

I am trying to use a field to store wat is best described as a summary and some text to populate a filed when selected.

It looks like this:

Neck-!-A group of 7 vertebrae called the cervical spine
Lower Back-!-A group of 5 vertabrae called the lumbar spine

What i am tryig to do is split the first parts (.*-!-) into a value list (as an array i assume) and then the second part into another array, so when the user selects the first part in a drop down list i can write a method to populate the dataprovider on the form with the second.

I just cant quite seem to get my regular expressions correct to sort them into an array.

Can anyone help! Thanks

David

Imho you don’t need regex here (although I love it). The JavaScript .split method is able to do it for you. Makes an array of your string```
var array=string.split(“-!-”)

Hi David,

I have to ask the question as to why you would not put this text block into a table breaking it into separate records ?

The table would have a ‘pk’ plus a column for category (e.g. ‘Neck’) and column for description (e.g. ‘A group of 7 vertebrae called the cervical spine’)

Choice is then a lot more controllable and less of an overhead in splitting the apporpriate data out and reconstructing somewhere else.

See this thread for a short discussion on arrays from table rows and regular expressions:

Also search the forum for ‘regular expression’ as there have been many posts alluding to it.

Hope this helps

Cheers
Harry

I see where you are coming from.

The reason i was looking to do it by splitting out a single field, is that i have 4 or five fields that need populating in this was and a multitude of Expert users whom will want to store their own definitions for medical prognoses.

The lists wont be more than 10 or 20 entries, and i suppose the correct method is to have a table with a customer primary key as well as a list type primary key.
i.e

PK_Row_ID FK_Expert FK_Listtype List_summary List_text

It just seemed that splitting out a single field that could be placed in the Expert_Customer file would allow me to write one script to deal with the four or five lists and not have a more complicated table structure, but i think technically you are correct.

I have hope to simply be able to populate 2 arrays or even a multidimensional array based on the value before the deliminator -!- and after as a fairly simple solution.

Thats harder then it looks though! I will look at that post. Thanks

I would just have a simple table that has:

PK ; FK (expert or userid); code (Neck, back, etc.); definition (7 vertebrae etc.)

Then each user is automatically linked by relationship (via userid) to their own definitions (if you display it that way) or you have a dynamic value list that uses that relationship to populate a pull down menu.