Hello Folks,
I'm quite new and have run into a bit of a roadblock. I'm attempting to get the value of the current and max values of the characters stats in the following line:
Sheynna < PC (Ne1) - 25(25)H 108(108)M 122(122)V> (Leader)
The issue I am running into is that the parentheses in the above line seem to cause issues with the code. The closest I am getting is:
^ Sheynna < PC (.*) - (\d+)((\d+))
matches[3] returns as 2 here instead of 25.
I'd appreciate any guidance you folks could offer.
Thank you!
How to get values from within parentheses
Re: How to get values from within parentheses
try
^Sheynna < PC \((.*)\) - (\d+)\((\d+)\)H (\d+)\((\d+)\)M (\d+)\(\d+\)V>
The parantheses that are actually in the line need escaping, because of that that first (.*) is matching (NE1), then the next match is 2, and the one after 5, because that's the only way it can parse that to make the regex match. The one I pasted above should hopefully capture the whole line and get your stats into the matches table.
Also, regex101.com can be a big help for making and testing these kinds of patterns.
^Sheynna < PC \((.*)\) - (\d+)\((\d+)\)H (\d+)\((\d+)\)M (\d+)\(\d+\)V>
The parantheses that are actually in the line need escaping, because of that that first (.*) is matching (NE1), then the next match is 2, and the one after 5, because that's the only way it can parse that to make the regex match. The one I pasted above should hopefully capture the whole line and get your stats into the matches table.
Also, regex101.com can be a big help for making and testing these kinds of patterns.
Re: How to get values from within parentheses
Thank you very much for the response! It's working perfectly!