locked
Regular Expression replaces special chars with numbers instead of string RRS feed

  • Question

  • User-21077800 posted

    I'm using the following to strip special characters out of a URL:

            Dim urlReg As New Regex("[^\d\w ]")
            inurl = urlReg.Replace(inurl, "")


    But when it replaces the special characters, it replaces them with their character codes. e.g: 36 for a "$"


    Could someone please advise me?


    Thanks.

    Wednesday, June 30, 2010 5:01 AM

Answers

  • User-1179452826 posted

    That would suggest you're getting a url encoded string in urlReg (i.e. eith 36 in place of $) and as such, your replace isn't doing anything at all.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, June 30, 2010 7:45 AM

All replies

  • User-1179452826 posted

    That would suggest you're getting a url encoded string in urlReg (i.e. eith 36 in place of $) and as such, your replace isn't doing anything at all.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, June 30, 2010 7:45 AM
  • User-21077800 posted

    Thanks, you're right.

    I was filtering data from a database, forgetting that prior to insertion, this data is filtered for special characters and they are converted to HTML character codes.

    Tuesday, July 6, 2010 7:35 AM