Created
May 30, 2009 13:54
-
-
Save lmarburger/120505 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
html = %{This is a test | |
This is only a test | |
<pre>This is | |
some text | |
in a PRE.</pre> | |
omg<pre></pre> | |
<pre></pre>stuff<pre></pre> | |
More text. | |
<pre>This is another</pre>} | |
regex = %r{<pre>[\s\S]*?</pre>|[^\r\n]+} | |
p html.scan(regex) | |
# => ["This is a test", "This is only a test", "<pre>This is\n\nsome text\nin a PRE.</pre>", "omg<pre></pre>", "<pre></pre>", "stuff<pre></pre>", "More text.", "<pre>This is another</pre>"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment