string manipulation problem
I simply need to remove the leading x amount of characters from a string. I have a username that looks like this: ADOMAIN\jsmith This is on my NT network of course. I would like to display only: jsmith I tried using string.split, but I keep receiving errors. This is the code I am trying now. <dtml-call "REQUEST.set('authU', _.string.split(AUTHENTICATED_USER, '\\')[-1])"> <dtml-var authU> I'll be using that variable elseware too. Thanks for you help! Greg
On Fri, Oct 04, 2002 at 08:09:44PM -0700, Greg wrote:
I simply need to remove the leading x amount of characters from a string. I have a username that looks like this:
ADOMAIN\jsmith
I would do this with a Python Script. return str(container.REQUEST.AUTHENTICATED_USER)[8:] should do the trick. Your DTML would be <dtml-call expr="REQUEST.set('authU', nameOfPythonScript)"> -Tim -- Tim Wilson | Visit Sibley online: | Check out: Henry Sibley HS | http://www.isd197.org | http://www.zope.com W. St. Paul, MN | | http://slashdot.org wilson@visi.com | <dtml-var pithy_quote> | http://linux.com
Wow, that's perfect! Thanks a bunch! Greg Tim Wilson wrote:
On Fri, Oct 04, 2002 at 08:09:44PM -0700, Greg wrote:
I simply need to remove the leading x amount of characters from a string. I have a username that looks like this:
ADOMAIN\jsmith
I would do this with a Python Script.
return str(container.REQUEST.AUTHENTICATED_USER)[8:]
should do the trick.
Your DTML would be
<dtml-call expr="REQUEST.set('authU', nameOfPythonScript)">
-Tim
better yet return str(container.REQUEST.AUTHENTICATED_USER).split("\\")[-1] this should work also with "aaa\yyy\c\....\username" robert Greg wrote:
Wow, that's perfect! Thanks a bunch! Greg
Tim Wilson wrote:
On Fri, Oct 04, 2002 at 08:09:44PM -0700, Greg wrote:
I simply need to remove the leading x amount of characters from a string. I have a username that looks like this:
ADOMAIN\jsmith
I would do this with a Python Script.
return str(container.REQUEST.AUTHENTICATED_USER)[8:]
should do the trick.
Your DTML would be
<dtml-call expr="REQUEST.set('authU', nameOfPythonScript)">
-Tim
participants (3)
-
Greg -
robert -
Tim Wilson