re = /(?<Loop>
(?<NewBlock>
(?:(?:
^[\s]*\n
|
^(?:(?!\/\*).)+\n
|
^(?:(?!\/\*).)+
))+
)?
(?<OldBlock>
(?:
\/\*.+\*\/
|
(?:\/\*.*\n)
(?:(?:
^[\s]*\n
|
^(?:(?!\*\/).)+\n
|
^(?:(?!\*\/).)+
))+
\*\/
)
)?
)+/mx
str = ' .highlight
{
background: #ffffff
}
.highlight .c,
.highlight .cm,
.highlight .cp,
.highlight .c1,
.highlight .cs
{
color: #007400;
}
/* Comment,
Comment.Multiline,
Comment.Preproc,
Comment.Single,
Comment.Special
*/
.highlight .k,
.highlight .kc,
.highlight .kd,
.highlight .kp,
.highlight .kr,
.highlight .nb
{
color: #AA0D91;
}
/* Keyword,
Keyword.Constant,
Keyword.Declaration,
Keyword.Pseudo,
Name.Builtin */
.highlight .kt
{
color: #3F6E74
}
/* Keyword.Reserved */
.highlight .err
{
color: #a61717;
}
/* Error */
.highlight .o
{
font-weight: bold
}
/* Operator */
.highlight .gd
{
color: #000000;
background-color: #fdd
}
/* Generic.Deleted */
.highlight .gd .x
{
color: #000000;
background-color: #faa
}
/* Generic.Deleted.Specific */
.highlight .ge
{
font-style: italic
}
/* Generic.Emph */
.highlight .gr
{
color: #a00
}
/* Generic.Error */
.highlight .gh
{
color: #999
}
/* Generic.Heading */
.highlight .gi
{
color: #000000;
background-color: #dfd
}
/* Generic.Inserted */
.highlight .gi .x
{
color: #000000;
background-color: #afa
}
/* Generic.Inserted.Specific */
.highlight .go
{
color: #888
}
/* Generic.Output */
.highlight .gp
{
color: #555
}
/* Generic.Prompt */
.highlight .gs
{
font-weight: bold
}
/* Generic.Strong */
.highlight .gu
{
color: #aaa
}
/* Generic.Subheading */
.highlight .gt
{
color: #a00
}
/* Generic.Traceback */
.highlight .m,
.highlight .mf,
.highlight .mh,
.highlight .mi,
.highlight .mo
{
color: #1C00CF;
}
/* Literal.Number,
Literal.Number.Float,
Literal.Number.Hex,
Literal.Number.Integer,
Literal.Number.Oct */
.highlight .s
{
color: #C41A16;
}
/* Literal.String */
.highlight .na
{
color: teal
}
/* Name.Attribute */
.highlight .nc
{
color: #5C2699
}
/* Name.Class */
.highlight .no
{
color: teal
}
/* Name.Constant */
.highlight .ni
{
color: purple
}
/* Name.Entity */
.highlight .ne
{
color: #990000
}
/* Name.Exception */
.highlight .nn
{
color: #555
}
/* Name.Namespace */
.highlight .nt
{
color: navy
}
/* Name.Tag */
.highlight .nv,
.highlight .nf
{
color: #3F6E74
}
/* Name.Variable,
Name.Function */
.highlight .ow
{
font-weight: bold
}
/* Operator.Word */
.highlight .w
{
color: #bbb
}
/* Text.Whitespace */
.highlight .sb
{
color: #d14
}
/* Literal.String.Backtick */
.highlight .sc
{
color: #d14
}
/* Literal.String.Char */
.highlight .sd
{
color: #d14
}
/* Literal.String.Doc */
.highlight .s2
{
color: #d14
}
/* Literal.String.Double */
.highlight .se
{
color: #d14
}
/* Literal.String.Escape */
.highlight .sh
{
color: #d14
}
/* Literal.String.Heredoc */
.highlight .si
{
color: #d14
}
/* Literal.String.Interpol */
.highlight .sx
{
color: #d14
}
/* Literal.String.Other */
.highlight .sr
{
color: #009926
}
/* Literal.String.Regex */
.highlight .s1
{
color: #d14
}
/* Literal.String.Single */
.highlight .ss
{
color: #990073
}
/* Literal.String.Symbol */
.highlight .bp
{
color: #999
}
/* Name.Builtin.Pseudo */
.highlight .vc
{
color: teal
}
/* Name.Variable.Class */
.highlight .vg
{
color: teal
}
/* Name.Variable.Global */
.highlight .vi
{
color: teal
}
/* Name.Variable.Instance */
.highlight .il
{
color: #099
}
/* Literal.Number.Integer.Long */
*,*:before,*:after
{
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box'
# Print the match result
str.scan(re) do |match|
puts match.to_s
end
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Ruby, please visit: http://ruby-doc.org/core-2.2.0/Regexp.html