Replace consecutive "-" chars with a single character

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Gabriela

    Replace consecutive "-" chars with a single character

    Hi,
    I would like to use VBScript regexp to locate multiple characters in a
    string and replace them with a single "-" char.
    In my case it's multiple "-" chars:
    E.g.: "Gabriela---Hello--How----Are-You" -->"Gabriela-Hello-How-Are-
    You"
    How is it done?
    Thanks, Gabi.
  • Martin Honnen

    #2
    Re: Replace consecutive "-" chars with a single character

    Gabriela wrote:
    I would like to use VBScript regexp to locate multiple characters in a
    string and replace them with a single "-" char.
    In my case it's multiple "-" chars:
    E.g.: "Gabriela---Hello--How----Are-You" -->"Gabriela-Hello-How-Are-
    You"
    How is it done?
    Dim s As String = "Gabriela---Hello--How----Are-You"
    s = Regex.Replace(s , "-{2,}", "-")

    --

    Martin Honnen --- MVP XML

    Comment

    • rowe_newsgroups

      #3
      Re: Replace consecutive "-" chars with a single character

      I would like to use VBScript regexp

      Martin has shown you how to do this in .NET, if you are truly needing
      a vbscript example, you will need to go to the vbscript group and not
      the .NET newsgroup.

      Thanks,

      Seth Rowe [MVP]

      Comment

      Working...