I'll come back later and answer that, but you really are experienced enough and have had enough answers about string functons, UPDATEs and REPLACEs, that you can do this on your own and don't need to come here with such questions. Just remember in a table fields have a fixed length, the right 2 characters are most often after the word stored, as you normally store textual data left aligned, so you can't test for RIGHT(field,2)="MX". Hint: you first have to trim away spaces.
If you have many more cases, it could also get simpler checking against a list of allowed colors and determine and remove everything else as junk. eg set fields to 'MAGENTA', if 'MAGENTA' $ field, etc.
Saif, in a question like this, you've really got to be precise about what you want to do. In your first post, it's not clear whether you want to remove any occurrence of the letters MX, regardless of where they appear in the string, or whether you want to remove the last two letters of the string.
Apart from that, I agree with the general tone of Olaf's reply. This is not to discourage you from asking questions here. But this is the sort of thing that you should be able to work out for yourself by perusing the Help file. There are no special techniques invovled.
And never be afraid to resort to good old trail and error.
Mike
__________________________________
Mike Lewis (Edinburgh, Scotland)
You can get surprising results, even if you think things through, so a copy is important to be able to get back to the initial situation. Things like this are not working by first solving the easiest case and then step forward, if you are confronted with many sepcific cases you turn the problem around and focus on the net data you want, not on the junk you want to get rid of.
Yes, that's exactly right. But the point is that you were able to find the answer yourself, presumably by looking at the string-handling function listed in the Help file.
By the way, even this solution is not strictly correct. That's because you did not specify how many instances of the substring ("MX") you want to remove. You solution will only work if the string only ever contains one instance, or if it contains multiple instances and you want to remove them all. Obviously, this isn't an issue in this case, but I hope you can see what I mean about defining the problem in precise terms.
Mike
__________________________________
Mike Lewis (Edinburgh, Scotland)
Poor people do not hire employees. If you soak the rich, who are you going to work for?
"We've found by experience that people who are careless and sloppy writers are usually also careless and sloppy at thinking and coding. Answering questions for careless and sloppy thinkers is not rewarding." - Eric Raymond
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.