Below is my javascript function which is already working...  but when i try to implement regular expression to check email is proper or not then my function does not work and does not display any message...  so plz suggest me how to implement this.  &lt;script language="javascript"&gt;  function validateFields(){    var error = '0';    var emailpattern =/^[a-zA-Z][a-zA-Z0-9_]*(\.[a-zA-Z0-9_]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*\.([a-zA-Z]{2,4})$/;     if(document.getElementById('InvitationEmailAddress').value==""){      document.getElementById('email_address_error').innerHTML = "Email address is required";      error = '1';    }    if(document.getElementById('InvitationEmailAddress').value!="")   {     if(!InvitationEmailAddress.value.match(emailpattern)){        document.getElementById('email_address_error').innerHTML = "Email address is not valid";      error = '1';    }else{      document.getElementById('email_address_error').innerHTML = "";    }  }      if(document.getElementById('InvitationMessage').value==""){      document.getElementById('message_error').innerHTML = "Welcome message is required";      error = '1';    }else{      document.getElementById('message_error').innerHTML = "";    }    if(error == 1){      return false;    }else{      return true;    }  } &lt;/script&gt;
291
Is there a regular expression to validate an email address in JavaScript?
123924
I'm trying to match a string pattern to any string in an array:  SELECT 'abc' LIKE ANY('{"abc","def"}') -- TRUE  -- BUT  SELECT 'ab%' LIKE ANY('{"abc","def"}') -- FALSE, I expect TRUE   What is wrong with the second query?
36235
I am after documentation on using wildcard or regular expressions (not sure on the exact terminology) with a jQuery selector.  I have looked for this myself but have been unable to find information on the syntax and how to use it. Does anyone know where the documentation for the syntax is?  EDIT: The attribute filters allow you to select based on patterns of an attribute value.
32215
I haven't used regular expressions at all, so I'm having difficulty troubleshooting. I want the regex to match only when the contained string is all numbers; but with the two examples below it is matching a string that contains all numbers plus an equals sign like "1234=4321". I'm sure there's a way to change this behavior, but as I said, I've never really done much with regular expressions.  string compare = "1234=4321"; Regex regex = new Regex(@"[\d]");  if (regex.IsMatch(compare)) {      //true }  regex = new Regex("[0-9]");  if (regex.IsMatch(compare)) {      //true }   In case it matters, I'm using C# and .NET2.0.
83873
Is it possible to do something like this?  var pattern = /some regex segment/ + /* comment here */     /another segment/;   Or do I have to use new RegExp() syntax and concatenate a string? I'd prefer to use the literal as the code is both more self-evident and concise.
108459
Are Python and JavaScript regular expression syntax identical?   If not, then:    What are the important differences between them Is there a python library that "implements" JavaScript regexps?
84007
i'm trying to set a list of string to an aura:attribute and i get this error:     Uncaught rerender threw an error in 'markup://aura:expression'   [info.$component$.$isValid$ is not a function]   that's the attribute:  &lt;aura:attribute name="parents" type="String[]"/&gt;   i call this function in js:  test: function(component){     var action = component.get("c.test");         //Set up the callback         var self = this;         action.setCallback(this, function(actionResult) {                   debugger;             component.set("v.parents", actionResult.getReturnValue());         });                 $A.enqueueAction(action);    }   and thats the function:  @AuraEnabled public static List&lt;String&gt; test(){     String[] a = new String[]{};     a.add('1');     a.add('2');     return a; }   please help Thanks
33592
I have a group of strings in Javascript and I need to write a function that detects if another specific string belongs to this group or not.  What is the fastest way to achieve this? Is it alright to put the group of values into an array, and then write a function that searches through the array?  I think if I keep the values sorted and do a binary search, it should work fast enough. Or is there some other smart way of doing this, which can work faster?
75718
I'm dynamically adding &lt;script&gt; tags to a page's &lt;head&gt;, and I'd like to be able to tell whether the loading failed in some way -- a 404, a script error in the loaded script, whatever.  In Firefox, this works:  var script_tag = document.createElement('script'); script_tag.setAttribute('type', 'text/javascript'); script_tag.setAttribute('src', 'http://fail.org/nonexistant.js'); script_tag.onerror = function() { alert("Loading failed!"); } document.getElementsByTagName('head')[0].appendChild(script_tag);   However, this doesn't work in IE or Safari.  Does anyone know of a way to make this work in browsers other than Firefox?  (I don't think a solution that requires placing special code within the .js files is a good one. It's inelegant and inflexible.)
47519
Every time a user posts something containing &lt; or &gt; in a page in my web application, I get this exception thrown.  I don't want to go into the discussion about the smartness of throwing an exception or crashing an entire web application because somebody entered a character in a text box, but I am looking for an elegant way to handle this.  Trapping the exception and showing     An error has occurred please go back and re-type your entire form again, but this time please do not use &lt;   doesn't seem professional enough to me.  Disabling post validation (validateRequest="false") will definitely avoid this error, but it will leave the page vulnerable to a number of attacks.  Ideally: When a post back occurs containing HTML restricted characters, that posted value in the Form collection will be automatically HTML encoded. So the .Text property of my text-box will be something &amp; lt; html &amp; gt;  Is there a way I can do this from a handler?
10465
Please support the use of nested expressions like  and (or ) when searching.  Looking here, on meta, at questions tagged   and at questions found with +search +tag +boolean I didn't see any information on this topic.
106126
I was debugging something and discovered some strangeness in JavaScript:  alert(1=='') ==&gt; false alert(0=='') ==&gt; true alert(-1=='') ==&gt; false   It would make sense that an implied string comparison that 0 should = '0'. This is true for all non-zero values, but why not for zero?
37436
I'm using  to check if a user-provided email address is valid. For example:  $email = $_POST['email']; if ( is_email( $email ) )     // Do something.   To the best of my knowledge, nothing in this function writes info to the database. Should I be sanitizing $email before I pass it to the function?
55117
I have a list, a list filter and two date filters(Start date and end date) in a page. First I have to filter list using this filters and then I have to approve whatever item are left in the list after filtering.  I am using the following JavaScript code.      &lt;script type="text/javascript"&gt;  //var siteUrl = '/projects/SharePoint2013-Demo/TimesheetManagementSystem/'; var oList = null; var web = null; var clientContext  = null;    function retrieveListItems() {  var filterValue =document.getElementById("ctl00_ctl41_g_1c91c2d4_fbbb_4792_8507_ba589e5be222_SpListPicker_SelectionBox"); var StartDate=document.getElementById("ctl00_ctl41_g_ed4beb82_8f7e_4389_bb35_a44188462aab_DateFilterPicker_DateFilterPickerDate");   var EndDate=document.getElementById("ctl00_ctl41_g_07c2185d_e903_4010_8a84_b2d9536a5549_DateFilterPicker_DateFilterPickerDate"); alert(filterValue.value ); alert(StartDate.value); alert(EndDate.value);       clientContext = new SP.ClientContext.get_current();     oList = clientContext.get_web().get_lists().getByTitle('TimeSheetList');     clientContext.load(oList);      clientContext.executeQueryAsync(LoadList, onQueryFailed);           }   function LoadWeb123(sender,args) {     //oList = web.get_lists().getByTitle('TimeSheetList');      //clientContext.load(this.oList);     //clientContext.executeQueryAsync(Function.createDelegate(this, this.LoadList), Function.createDelegate(this, this.onQueryFailed));     }    function LoadList() {            var  camlQuery= new SP.CamlQuery();                    camlQuery.set_viewXml("&lt;View&gt;&lt;Query&gt;&lt;Where&gt;&lt;And&gt;&lt;And&gt;&lt;Eq&gt;&lt;FieldRef Name='Author'/&gt;&lt;Value Type='User'&gt;vikash kumar&lt;/Value&gt;&lt;/Eq&gt;&lt;Geq&gt;&lt;FieldRef Name='Date' /&gt;&lt;Value Type='DateTime'&gt;2015-07-10T12:00:00Z&lt;/Value&gt;&lt;/Geq&gt;&lt;/And&gt;&lt;Leq&gt;&lt;FieldRef Name='Date' /&gt;&lt;Value Type='DateTime'&gt;2015-07-17T12:00:00Z&lt;/Value&gt;&lt;/Leq&gt;&lt;/And&gt;&lt;/Where&gt;&lt;/Query&gt;&lt;/View&gt;");       camlQuery.set_viewXml(camlQuery);      this.collListItem = oList.getItems(camlQuery);       clientContext.load(collListItem);     clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));     }    function onQuerySucceeded(sender, args) {      var listItemInfo = '';       var listItemEnumerator = collListItem.getEnumerator();      while (listItemEnumerator.moveNext()) {                 var oListItem = listItemEnumerator.get_current();                 var ID= oListItem.get_id();                 alert(ID);                 } }   function onQueryFailed() { //    alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());     alert('error'); }   &lt;/script&gt;  &lt;button type="button" onclick="retrieveListItems()"&gt;Approve!&lt;/button&gt;   But this is not working, it gives error alert.  What could be done? Is there anything wrong with the code?
30755
How can I check if a string ends with a particular character in JavaScript?  Example: I have a string   var str = "mystring#";   I want to know if that string is ending with #. How can I check it?   Is there a endsWith() method in JavaScript? One solution I have is take the length of the string and get the last character and check it.   Is this the best way or there is any other way?
58910
I'm especially terrible with Regex, but reworked one I found online to suit my needs, but it keeps throwing the "no viable alternative at character '\'" error. This pattern works when tested in regex101.com, regexplanet.com, and rubular.com. I thought I had escaped everything that needed escaping. Right, now  I'm out of my depth with this. Hopefully someone here can give me some insight.  In case anyone needs to know, the regex needs to find the first email address in an the email body (which is from a submitted form) that immediately follows the word "From:" (at this point I'm unsure if there will be a space after "From:" or not), since there could be multiple email addresses in the text.  Thanks in advance to anyone who can help!  Here's my code:  if (email.Subject.Contains('xxxx') || email.fromAddress == 'xxxx'){         Pattern myPattern = Pattern.compile('From:(\\s(?:[a-z0-9!#$%&amp;'*+\\/=?^_'{|}~-]+(?:\\.[a-z0-9!#$%&amp;'*+\\/=?^_'{|}~-]+)*|\"(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21\\x23-\\x5b\\x5d-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])*\")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21-\\x5a\\x53-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])+)\\]))');         Matcher myMatcher = myPattern.matcher(email.plainTextBody);         Set&lt;String&gt; emails = new Set&lt;String&gt;();         while(myMatcher.find()) {             emails.add(matcher.group(1));         }     }
74930
Here's an example of a Google Docs Spreadsheet script that sends emails using Google spreadsheets. I want the email Sent in HTML not plain text. Can someone help me out?  function sendEmails() {   var sheet = SpreadsheetApp.getActiveSheet();   var startRow = 2;  // First row of data to process   var numRows = 2;   // Number of rows to process   // Fetch the range of cells A2:B3   var dataRange = sheet.getRange(startRow, 1, numRows, 2)   // Fetch values for each row in the Range.   var data = dataRange.getValues();   for (i in data) {     var row = data[i];     var emailAddress = row[0];  // First column     var message = row[1];       // Second column     var subject = "Sending emails from a Spreadsheet";     MailApp.sendEmail(emailAddress, subject, message);   } }