RegEx for Getting a value from the note tag

I just want to ask how are you able to get the value of a note tag on a certain tab? Here's an example:

<hertz: 90>

I want to know how to get that 90 from the note tag <hertz: x> (which x is the value) and store it in a variable.

Thanks a lot.
i usually use match

comment = "<hertz: 90>";result = comment.match(/<hertz:\s*(\d+)?>/im)[1];tonumber = Number(result);return tonumber;this site is really helpful for testing regexp... i found lots of bugs when testing using this site and fix finally fix it.

https://regex101.com/

edit: if you want to get it from item note... for example item 1

change

comment = "<hertz: 90>";to

comment = $dataItems[1].noteother example:comment = $dataWeapons[10].note // weapon 10 in databasecomment = $dataArmors[7].note // armor 7 in databaseyou could also pass item object instead and grab it's note by .note

if you want it from comment in event page... it's a bit tricky though...

edit2: to grab from current map event 7

var comment = "";event = $gameMap._events[7];if (event && event.page()){var pagelist = event.page().list;   for (cmd of pagelist)   {        if(cmd.code == 108)     comment += cmd.parameters[0] + "\n";        if(cmd.code == 408)     comment += cmd.parameters[0] + "\n";            }}result = comment.match(/<hertz:\s*(\d+)?>/im)[1];tonumber = Number(result);return tonumber;you could pass Game_Event object rather than using $gameMap._events[7] too...

hope this help...

some example of using event comment tag... you can see it inside my plugin... link in my signature...
Is the first line needed for that? I'm trying to learn this too so am curious.
How about simple strings? For example:

<invisible>

How do you read them?
Or you could just use .meta:

Code:
var hz = Number(item.meta.hertz);console.log(hz) // 90
Edit: for single strings .meta returns true if it exists and false if not:
Code:
var inv = item.meta.invisible;console.log(inv) // true
I see, thanks Masked. If it returns true, then how can you print the value instead of its type?

for example in pseudocode:

if <invisible> 

 then do this

close if statement
You mean, like this?

Code:
if (item.meta.invisible) {  console.log(...) // invisible}
I'm not sure I understood what you want...
I mean, how do we check if the note tag is indeed "<invisible>", instead of printing true or false for it.
Oh, I see. You can check if it's really 'true' or if it's a string, if it has any value assigned to it then the .meta will be a string, if its just an empty tag then the .meta will be a boolean.

Something like this:

Code:
if (item.meta.invisible === true) {    // <invisible>} else if (typeof item.meta.invisible == "string") {    // <invisible:something>}
Before my friend wrote an awesome Regex parser I used: http://rubular.com/ to create regex. Now I use his epic script that parses this jazz 😀

Original thread: https://forums.rpgmakerweb.com/threads/regex-for-getting-a-value-from-the-note-tag.48994/