Wrox Programmer Forums
|
ASP Forms As of Oct 5, 2005, this forum is now locked. Please use "Classic ASP beginner" at http://p2p.wrox.com/forum.asp?FORUM_ID=54 or "Classic ASP Professional" http://p2p.wrox.com/forum.asp?FORUM_ID=56 instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP Forms section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 7th, 2003, 01:34 PM
Authorized User
 
Join Date: Sep 2003
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default Remove last character

I am trying to remove a string which last character is either "--" or "-" ... I can only get "--" work ... but not "-" ... My code as follow:-
===================
sISBNNode.text = Left(sISBNNode.text, 1) & "-" & Mid(sISBNNode.text, 2, 6) & "-" & Mid(sISBNNode.text, 8, 2) & "-" & Mid(sISBNNode.text, 10, 1)
      'This works
        if Right(sISBNNode.text, 2) = "--" then
             sISBNNode.text = replace(sISBNNode.text, right(sISBNNode.text, 2), "")
        end if

           'This is not working, it replace ALL the "-" with "", not just the last "-"
        if Right(sISBNNode.text, 1) = "-" then
             sISBNNode.text = replace(sISBNNode.text, right(sISBNNode.text, 1), "")
        end if


 
Old November 7th, 2003, 02:17 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 184
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Jonax
Default

Quote:
quote:
      'This works
        if Right(sISBNNode.text, 2) = "--" then
             sISBNNode.text = replace(sISBNNode.text, right(sISBNNode.text, 2), "")
        end if

           'This is not working, it replace ALL the "-" with "", not just the last "-"
        if Right(sISBNNode.text, 1) = "-" then
             sISBNNode.text = replace(sISBNNode.text, right(sISBNNode.text, 1), "")
        end if
The first part only works because you don't have the string "--" at other positions in your string...
The following code strips off the last one/two character(s) instead of replacing the pattern...
Code:
        if Right(sISBNNode.text, 2) = "--" then         
             sISBNNode.text = left(sISBNNode.text, len(sISBNNode.text)-2)        
        end if

        if Right(sISBNNode.text, 1) = "-" then         
             sISBNNode.text = left(sISBNNode.text, len(sISBNNode.text)-1)        
        end if





Similar Threads
Thread Thread Starter Forum Replies Last Post
remove carriage return character in a textbox maricar C# 5 September 15th, 2017 09:38 AM
character entity into numeric character entity srkumar XSLT 1 November 22nd, 2007 04:53 AM
remove node asap XSLT 1 July 30th, 2006 03:01 AM
How to remove ? abdusalam Javascript How-To 1 July 27th, 2004 01:24 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.