You might consider just using a more generalized selector such as span.error-message:contains('...') and just using jQuery's text() function to set the content :
$("span.error-message:contains('Password and email do not match')").text('Password does not match');
If you need it to be more specific, you could use an identifier like #pattern from your example code :
$("#pattern span.error-message:contains('Password and email do not match')").text('Password does not match');
You can see a very basic example demonstrated below :
<!DOCTYPE html> <html> <head> <script src="https://code.jquery.com/jquery-2.1.4.js"></script> <meta charset="utf-8"> <meta name="viewport" content="width=device-width"> <title>JS Bin</title> </head> <body> <pre>Original</pre> <span class='original-error-message'> Password and email do not match </span> <pre>Replaced</pre> <span class='error-message'> Password and email do not match </span> <script language="JavaScript"> $(function() { // Replace any spans with class 'error-message' that contain // your specific text $("span.error-message:contains('Password and email do not match')").text('Password does not match'); }); </script> </body> </html>