contains match only substring. what about full text? thoughts and solution

contains match only substring. what about full text? thoughts and solution


Hi all.
I work with jQuery to manage some XML files.
suppose this XML data:
<xml>
<field_name>4a</field_name>
<field_name>4ab</field_name>
</xml>
I need to find the field that contains the word "4a". not "4ab".
In this case, $('FIELD_NAME:contains("4a")') will match also 4ab.
Contains makes use of "indexOf", but to obtain a whole-word
recognition a simple "==" operand will do the trick.
I searched the documentation and the source code and I cannot find a
solution, so I implemented a very small plug-in. The plug-in works
with this code: $('FIELD_NAME:equals("4a")')
Here's the micro-plugin code:
jQuery.extend(jQuery.expr[":"], {
equals: "(a.textContent||a.innerText||jQuery(a).text()||'')==m[3]",
});
Do you think it's a good idea to include this in the main code?
Or am I blind and my solution is unwanted or already present or lame?
Thanks all