PDA

View Full Version : Pattern matching?


Dylan Leblanc
05-31-2003, 08:13 PM
I have some data I want to pull out of one field and put into another. The tricky part is that the field the data is in is a text field, and the data could be anywhere in there. So I need to do some sort of pattern matching to find it.

Here is an example of the query I want to run, but I don't know what to put for the question mark.

UPDATE Building SET architect = ? WHERE description LIKE '%Architect: %';


In the description field, architects are in this format:

Architect: name of architect
or
Architect: name of architect, http://example.com/

The name of the architect may contain commas.


So the pattern match needs to do this:
Find "Architect: "
then find ", http://" or "\n" or end of field after that
take the text in between and put it in the architect field.

Can this be done?

raf
06-01-2003, 10:07 PM
Everything can be done :D
In general, working with 'composit values' in bad, bad, bad. I never do it so i never get this sort of problems. But i think that some regex's could solve it.
Thi should get you started for a pleasant evening
http://www.mysql.com/doc/en/Regexp.html