c# - Regular expression replace -


I need a reg X script

  • Delete all symbols
  • Example:

    • Mike & amp; Ike Output Mike Iki is the output: Mike-Iki
    • Mike-Ike-Jill The output is: Mike-Ike < Li> Ike-Jill
    • Mike - Ike-Jill Output is: Mike-Ike-Jill
    • Mike - IK-Jill Output is: Mike-Ike-Jill
    • Mike.K.Bill Output is: Mike Ikeley
    • Mike ** * which is Output: Mike Jo
    • Mike 123 Output is: Mike 123

      You can do something with many passes.
      This is the usual kind of normal type that can be reduced by using look-bihund.
      (Not all Reggae flavors support this)

      1. Delete multiple - with reg - {2,}
      2. Remove symbols except -. with regex [^ - \. A-Za-z0-9]
      3. Change to the first . with a floating character! Change and the rest .
      4. ! Use from to the last step Li>

        update .)

          string str = "Mike and Ike .. .... "; Str = Regex. Change (str, @ "- +", @ "-"); Str = Regex. Replace (str, @ "(? & Lt; = \.) (. *?) \.", @ "$ 1"); Str = Regex.Replace (str, @ "[^ \ w \ r \ n]", @ ""); Remove   
        1. Delete -
        2. with - and delete . If this is not the first . using positiv lookbehind (? & Lt; = ...)
        3. Remove symbols (not really everything word or new line) < Less for Code> \ w [A-Za-z0- 9]

Comments