mos wrote:
Ok, put your thinking caps on because this one bit of a toughie.
I an Update statement that will insert a '/' in front of the *first* lowercase letter of a field value.
Example: "ABCDef" becomes "ABCD/ef".
Of course it doesn't always end in "ef" and could be any 2 or 3 group of letters like "ABcde" becomes "AB/cde".
Any idea on how to do this? Or should I do it manually?
TIA
Mike
I assume you've already made sure that the column with the letters is wide enough to hold an additional character.
Not sure what you mean by manually. I'd probably do it in perl, as it's almost a one-liner ($field =~ s/([a..z])/\$1/). In mysql, though, the problem seems to be that while we can match with a regular expression, we can't replace with one. Hmm...
Being an official perl hater I don't know the exact syntax with out looking it up, but I am sure perl can do the search and replace in one line. Here is how you would do it if this column were lines of text in vi
:%s/[a-z]*$/\/&/
this is basically saying find a group of any number of lower case letters at the end of the line and then replace it with a / and then the string that matched the search and do this on every line. I'm not sure why the $ needs to be there but it didn't work right with out it. Now if I were to guess at the perl equivalent of this it would look something like this.
$fielsd =~ s/[a-z]*$/\/$1/;
-- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]