I already reviewed this one , which was useful for the point.
Here is the problem. I have a list of users that propagate to an element through a user click; something like that:
<div id="box">
joe-user
page-joe-user
someone-else
page-someone-else
</div>
In a click, I want to make sure that the user has not yet clicked on the div. So, I am doing something like:
if ( ! $('#box').html().match(rcpt) )
{
update_div();
}
else
{
alert(rcpt+' already exists.');
}
However, given the lack of interpolation that javascript has for regular expressions, I get my warning to run in the use-case where it is page-joe-userselected, and then the user selects joe-userwhich are clearly not exactly the same.
In Perl, I would do something like:
if ( $rcpt =~ /^\Qrcpt\E/ )
{
}
All I want to do is change my match () as:
if ( ! $('#box').html().match(/^rcpt/) )
{
}
if ( ! $('#box').html().match(rcpt) ) , . new RegExp() , RE IE $('#box').html().match(new RegExp('^'+rcpt)). $('#box').html().match('/^'+rcpt'/'). , - . javascript.
, -, , , .