Advertisement
Guest User

basic html escape

a guest
May 5th, 2015
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
F# 0.58 KB | None | 0 0
  1.     let ESCAPE (s: string) =
  2.         let rec REMOVE_TAGS (acc: string) (s: string) =
  3.             let next (c: char) =
  4.                 try
  5.                     Some <| s.IndexOf(c)
  6.                 with
  7.                 | _ ->
  8.                     None
  9.             match next('<'), next('>') with
  10.             | Some i, Some j when i < j ->
  11.                 REMOVE_TAGS <| acc + s.Substring(0, i) <| s.Substring(j+1)
  12.             | _, _ ->
  13.                 acc + s
  14.         let res =
  15.             s
  16.             |> REMOVE_TAGS ""
  17.             |> System.Web.HttpUtility.HtmlDecode
  18.         res
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement