notetags are characters in a text box.
you can grab the contents of the text box, but the program can't possibly know what they mean.
you have to compare the contents of the text box with a blueprint of meaning and see if they match.
your blueprint is the result of a constant in a module.
Code:
module RD
module Skill
Ext_Regex = <desc>(.*)<\/desc>
end
end
the content of the text box, contains line break characters.
Code:
<desc> (break)
Line1 (break)
Line2 (break)
</desc>
when you read the contents of the text box as a string, it comes out as
Code:
<desc>(\n)Line1(\n)Line2(\n)</desc>
does
Code:
<desc>(\n)Line1(\n)Line2(\n)</desc>
resemble
Code:
module RD
module Skill
Ext_Regex = <desc>(.*)<\/desc>
end
end
?
yes.
Code:
<desc>(\n)Line1(\n)Line2(\n)</desc>
is a line of stuff preceded by <desc> and followed by </desc>.
for all intents and purposes of the comparison,
Code:
<desc>(\n)Line1(\n)Line2(\n)</desc>
resembles
therefore:
Code:
res =~ RD::Skill::Ext_Regex
returns true.
but you need to retrieve the actual line, which is *the stuff in between <desc> and </desc>*.
SO:
Code:
res = self.note =~ RD::Skill::Ext_Regex ? $1 : nil
OR:
Code:
res = self.note[RD::Skill::Ext_Regex]
which is the same as
Code:
res = self.note[/<desc>(.*)<\/desc>/i]
which is what you want to extract.
it'll still come out as
so you need to remove the line breaks and split the lines into individual values.
(MODERATORS: Sorry for wall post. I can't simply point at the code in question and state "this!" while I point at it if the OP can't possibly know what I'm pointing at unless I write the actual thing I want to reference. Can't sum up *programming* as *this! goes here! outputs stuff, there!*)