|
|
|||||||
Hi All! It's been a while since I wrote a question here, but now I'm stuck. Hopefully someone can answer this. If I have a string that looks like this: "abclefgh" How do I replace the "l" with a "d" ? The problem is that the lenght of the string is not constant and it's not always "l" that has to be replaced. Problem 2: If I have for example a name that looks like this: "John-patrick" How do I change that to "John-Patrick" ? T.I.A |
||||||||
|
|
|||||||
Maybe this UDF might help. If not it will give you some ideas. String replacement function |
||||||||
|
|
|||||||
In 4.10 or higher: $a = join(split("abclefgh","l"),"") |
||||||||
|
|
|||||||
For the case issue, you can use SetOption( ) to turn on case sensitivity and possibly do something like above with "-p" and "-P". [ 24. September 2002, 17:04: Message edited by: Howard Bullock ] |
||||||||
|
|
|||||||
For case sensitivity, could always do the == thing. code:Break on |
||||||||
|
|
|||||||
Thanks!! The "a = join(split("abclefgh","l"),"")"-thing got me halfway... But I'm still stuck on "problem 2" Let me try and clarify it a bit. I'm readin an input-file, make som changes and saves in an output-file like this: Input: Output: SMITH JOHN John Smith;john.smith OLSEN JOHN-PATRICK John-patrick Olsen;john-patrick.olsen ANDERSON ANNA-GRETA Anna-greta Anderson;anna-greta.anderson I need an "easy" way to change the first letter after the "-" to uppercase I tried with Join & Split, but my code just grew to something like 4 pages, so there must be an easier way (I hope...) |
||||||||
|
|
|||||||
well, for making the first char upper and others low with split and join: code:then, for the "-" do the same:$fullname=split($fullname) code:cheers.$fullname=split($fullname,"-")   |
||||||||
|
|
|||||||
Try this: code:{edit} Beat out again by the one that never sleeps.$a="OLSEN JOHN-PATRICK" [ 25. September 2002, 17:54: Message edited by: Howard Bullock ] |
||||||||
|
|
|||||||
Proper names are not nice. You need to deal with stuff like O'Neil, MacDonald, and double names with & without hyphens, plus more. Once you start down the path of displaying the users names correctly, it may lead farther then you think. |
||||||||
|
|
|||||||
YES!!! It works!! Thanks guys! Jack: I know, but I got a note the other day that said "Fix This NOW!" from my boss, so now the next step is to make him understand that this can't be done on every combination of names. Thanks again! // Viggen |