Loading ...
Sorry, an error occurred while loading the content.

RE: Help with regex substitution

Expand Messages
  • Michael Geddes
    s/ (^ @!+ |[^+0-9] )//g This copes with (09) 20398203 20398 as well as +123 02394823 It assumes the + at the start of the line so it will work like this as
    Message 1 of 3 , Apr 29 10:08 PM
    • 0 Attachment
      s/\(^\@!+\|[^+0-9]\)//g

      This copes with
      (09) 20398203 20398

      as well as
      +123 02394823

      It assumes the + at the start of the line

      so it will work like this as well:
      echo substitute('+1234 23923+32', '\(^\@!+\|[^+0-9]\)', '','g')

      Break-up of the line:
      \(
      ^\@!+ << Match a '+' character not at the beginning of the line
      \|
      [^+0-9] << Match anything that isn't a digit or a +
      \)


      //.ichael G.

      -----Original Message-----
      From: vim@... [mailto:vim@...]
      Sent: Wednesday, 30 April 2003 4:47 AM
      To: vim@...
      Subject: Help with regex substitution


      Given a string with a leading "+", I want to keep the leading "+" and
      strip out all non-numerics from the rest of the string. How can I do
      this?

      i.e. given the following

      + +1 011-377-93-10-4555

      I want

      +101137793104555

      Thanks for any help



      _______________________________________________________
      The FREE service that prevents junk email http://www.mailshell.com
    Your message has been successfully submitted and would be delivered to recipients shortly.