Jump to content

Simolinic

Member
  • Content Count

    2
  • Joined

  • Last visited

Reputation Activity

  1. Like
    Simolinic reacted to vitor in MarkdownTransform — Convert Markdown to other formats   
    Thank you for the kind words.
    On to your problem. You’re escaping too much: you don’t actually need to escape any of the characters, as they’re not special (the ones that are need to be there unescaped, anyway). You’re also trying to substitute for a space (' '), when you should be substituting by nothing (''). When you say (\S.*?), what you’re saying is “capture one non-whitespace character, followed by any character zero or more times, until it finds your closing condition”. You don’t need capturing, or the non-whitespace definition. You were on the right track, just needed to remove the extra stuff.
    You said it should take into account text between {>> and <<}, but your example is showing something different (between {<< and >>}. I’ll take your first reference as guide. The line should read

    s = s.gsub /{>>.*?<<}/m, '' The m means you can have multi-line comments.Keep in mind this solution substitutes by nothing (meaning “something empty”, as opposed to deleting), so if you have a comment by itself on a line, it will still leave an empty line.
    On a tangent note, I recommend rubular to test out ruby regular expressions in real time.
×
×
  • Create New...