javascript,jquery,regex,string-parsingRelated issues-Collection of common programming errors


  • John Snow
    javascript google-maps animation google-maps-api-3 google-maps-markers
    I have a simple javascript maps application that I’m working on that requires me to animate the movement of multiple markers between different coords. Each marker is free to move on its own and all markers are stored in an array list. However, I have been having trouble getting them to smoothly transition locations.I’ve done a ton of research and trial/error but no luck, anyone have any luck with this?

  • pvorb
    javascript node.js foreach v8
    I wanted to use for each … in with Node.js (v0.4.11).I use it like this:var conf = {index: {path: {first: “index.html”,pattern: “index/{num}.html”},template: “index.tpl”,limit: 8},feed: {path: “feed.xml”,template: “atom.tpl”,limit: 8} }for each (var index in conf) {console.log(index.path); }I get the following error:for each (var index in conf) {^^^^node.js:134throw e; // process.nextTick error, or ‘error’ event on first tick^ SyntaxError: Unexpected identifierat Module._compile (module.js:397

  • Peter Mortensen
    javascript programming-languages crockford
    This question already has an answer here:Calling member function of number literal3 answersI’m reading through Douglas Crockford’s JavaScript: The Good Parts, and I’m at the point where he defines a fade function. Part of this code boils down to this:var level = 1; var hex = level.toString(16);So I run this in my browser’s console to see what I get….var level = 1; level.toString(16);Hey, it returns “1”… Fabuloso! Wunderbar!Then to be cheeky, I try this to see what I get…1.toString(16);and

  • LukeS
    javascript jquery html scrolling mobile-browser
    I am trying to scroll to a specific location in a scrolling DIV. Right now I am using a pixel offset with the jQuery scrollTop() function which works great on desktop browsers but it does not work on android mobiles browsers with the exception of Google’s Chrome Android browser (do not have an iOS device to test if that works). All the solutions I have found are for page (window) scrolling and not for scrolling in a DIV, anyone have any suggestions on what else I can use to accomplish the same

  • muntoo
    javascript dhtml
    I want to create a simple bit of JS code that creates an image element in the background and doesn’t display anything. The image element will call a tracking URL (such as Omniture) and needs to be simple and robust and work in IE 6 =< only. Here is the code I have:var oImg=document.createElement(“img”); oImg.setAttribute(‘src’, ‘http://www.testtrackinglink.com’); oImg.setAttribute(‘alt’, ‘na’); oImg.setAttribute(‘height’, ‘1px’); oImg.setAttribute(‘width’, ‘1px’); document.body.appendChild(

  • Tim
    javascript jquery asp.net ajax
    I have a modal dialog on my page using jQuery that a user enters a password into.It’s a standard jQuery dialog and it works fine. I have linkbuttons in a datagrid that open the dialog using this code:$(‘.needsVal’).click(function () {$(“#login1”).dialog(‘open’);id = $(this).attr(‘id’);return false;});The problem is later on in the page I make an Ajax call, and based on the value returned, I want to selectively fire a postback for the page. The problem is the postback never fires. My postback cod

  • Marek Lipka
    javascript ruby-on-rails heroku
    So I’m a newbie and I am having issues deploying my code onto Heroku. I keep getting this error response. It looks like a JS Parse Error, which I have no idea what it could be. ANY help would be amazing. Thanks!I was successfully able to upload my previous application. I worry that it was because I tried to install some JQUERY plugins and it deleted the info inside my JS folderRunning: rake assets:precompileI, [2013-12-10T02:45:51.431542 #852] INFO — : Writing /tmp/build_63a972cd-66ca-44

  • khellang
    php javascript jquery ajax
    Basically I am trying to post a comment via AJAX and then load the new comment into the HTML. I am having a problem with what I think is my AJAX success function. The data gets added to the database fine, but I still get an error “Sorry, unexpected error. Please try again later.” as set inside the success function itself.JS:function newComment(event) { event.preventDefault();//Get the data from all the fieldsvar comment = $(‘textarea’);var product_id = $(‘input[name=product_id]’);var form

  • JrnDel
    javascript multidimensional-array
    I’m trying to construct a multidimentional array in javascript, so far without succes. I’ve read some other posts here on Stackoverflow, and read/watched tutorials on the subject, all have helped me but but I can’t get it to work.Most of the time I get the following error:Uncaught SyntaxError: Unexpected tokenBasically, I’ve got a form where the visitor of my website can input their age, bloodpressure, cholesterol and if they’re a smoker of not.riscTable = { ’68’: { // AGE’170′: { //

  • Connor Leech
    javascript angularjs gruntjs angularjs-ng-include
    When I deploy my unminified code everything works great. Then I run grunt build and deploy from the dist folder, as you do. When I check out one of the pages though it breaks and I get an error in the console: Error: [$parse:lexerr] Lexer Error: Unexpected next character at columns 0-0 [\] in expression [\]. http://errors.angularjs.org/1.2.6/$parse/lexerr?p0=Unexpected%20nextharacter%20&p1=s%200-0%20%5B%5C%5D&p2=%5Cat https://353a23c500dde3b2ad58-c49fe7e7355d384845270f4a7a0a7aa1.ssl.cf2

  • LukeS
    javascript jquery html scrolling mobile-browser
    I am trying to scroll to a specific location in a scrolling DIV. Right now I am using a pixel offset with the jQuery scrollTop() function which works great on desktop browsers but it does not work on android mobiles browsers with the exception of Google’s Chrome Android browser (do not have an iOS device to test if that works). All the solutions I have found are for page (window) scrolling and not for scrolling in a DIV, anyone have any suggestions on what else I can use to accomplish the same

  • Raynos
    jquery ajax node.js express
    Having some trouble getting express to respond properly to my jquery ajax request. The actual posting is working fine, but no matter what I try I cant seem to actually get a data response from my app that I can use. At first it was just posting and hanging constantly, and like a minute later it would respond with an alert that said something like “XML Document loaded” (have no idea where it was coming from) — Anyways, now its giving meSyntaxError: Unexpected token ILLEGALat parse (native)at Inc

  • Tim
    javascript jquery asp.net ajax
    I have a modal dialog on my page using jQuery that a user enters a password into.It’s a standard jQuery dialog and it works fine. I have linkbuttons in a datagrid that open the dialog using this code:$(‘.needsVal’).click(function () {$(“#login1”).dialog(‘open’);id = $(this).attr(‘id’);return false;});The problem is later on in the page I make an Ajax call, and based on the value returned, I want to selectively fire a postback for the page. The problem is the postback never fires. My postback cod

  • Kfirprods
    c# jquery asp.net ajax token
    I just tried to use a token that I generate on the handler and return to the client-side for authentication purposes. (Purpose: Authenticating all requests with the token, other than the first authentication step)I tested and the client-side does get token, but the described error with the “parsererror” status and “Unexpected Token T” syntax error are given when trying a method involving authentication by token.Code to GENERATE the token which is working wellbyte[] time = BitConverter.GetBytes(D

  • khellang
    php javascript jquery ajax
    Basically I am trying to post a comment via AJAX and then load the new comment into the HTML. I am having a problem with what I think is my AJAX success function. The data gets added to the database fine, but I still get an error “Sorry, unexpected error. Please try again later.” as set inside the success function itself.JS:function newComment(event) { event.preventDefault();//Get the data from all the fieldsvar comment = $(‘textarea’);var product_id = $(‘input[name=product_id]’);var form

  • rism
    javascript jquery json jqzoom
    I am using jqZoom, a jquery plugin, to render an image gallery.jqZoom Project PageThe docs say to create thumbnails like this:<a class=”zoomThumbActive” href=”javascript:void(0);” rel=”{gallery: ‘gal1’, smallimage: ‘./imgProd/SMALLIMAGE1.jpg’,largeimage: ‘./imgProd/LARGEIMAGE1.jpg’}”> <img src=”imgProd/thumbs/THUMBIMG1.jpg”> </a>which works if you use “regular” names as per example. But my images have guids as names and the plug in fails:Uncaught SyntaxError: Unexpected toke

  • Zee Tee
    jquery
    I have a form that uses .delegate to apply input validation to the form however, it appears any form with quotes just disappears.. No errors, the quote just disappears. Anyone know why this is happening? The only work around is to output the default value in the textbox as & #34; otherwise, the quotes will not appear in the textbox, even if it is actually in the value (view source).The input type=”text” also uses CSS3 styling, not sure if this has anything to do with it..Basically, input ty

  • mburm
    jquery vb.net jquery-ajax jquery-autocomplete ashx
    I use a jQuery autocomplete with an ASHX as source. But every request throws an error with number 200.My JavaScript:$(function () {$(‘#username input[type = “text”]’).autocomplete({source: function (request, response) {$.ajax({url: “UserName.ashx?term=” + request.term,dataType: “json”,type: “POST”,success: function (data) {response($.map(data, function (item) {return {label: item.Value}}))},error: function (xhr, ajaxOptions, thrownError) {alert(xhr.status);alert(thrownError);}});}}); });The HTML

  • Balaji Kandasamy
    php jquery ajax json
    I’ve tried many methods, from tutorials and other questions posted but nothing seems to work. I’m trying to get data sent from php into divs and variables with jquery. I have the array set up on the php side, and everything works fine but on the jquery side i always get an unexpected identifier error or the div is left blank or bothvar var_numdatacheck = <?php echo $datacheck; ?>;var var_rowtest = parseInt(var_numdatacheck);function waitupdate(){$.ajax({type: ‘POST’,url: ‘update.php’,data

  • user3318208
    jquery
    I have here an add record. I unbind the save button to prevent duplicating record. But the problem is when i try to add new record, the save button still disable. I try to use bind again but it doesn’t work.Help please$(document).ready(function(){$(“#save”).click(function(){$(‘#save’).unbind( “click” );ajax(“save”);});//$(document).on(‘click’, ‘#save’, function() {//ajax(“save”);//});$(“#add_new”).click(function(){$(“.entry-form”).fadeIn(“fast”);});$(“#close”).click(function(){$(“.entry-form”).f

  • Rohit Jain
    java regex string split
    I’m making a text based dice roller. It takes in strings like “2d10+5” and returns a string as a result of the roll(s). My problem is showing up in the tokenizer that splits the string into useful parts for me to parse into information.String[] tokens = message.split(“(?=[dk\\+\\-])”); This is yielding strange, unexpected results. I don’t know exactly what is causing them. It could be the regex, my misunderstanding, or Java just being Java. Here’s what’s happening: 3d6+4 yields the string array

  • Bill the Lizard
    java regex
    I am facing an issue with my regular expression. Java is hanging with 100% CPU usage when I use the below string as input for a regular expression. RegEx Used: Here is the regular expression used for the description field in my application.^([A-Za-z0-9\\-\\_\\.\\&\\,]+[\\s]*)+String used for testing:SaaS Service VLAN from Provider_One2nd attempt with Didier SPT because the first one he gave me was wrong :-(It works properly when I split the same string in different combinations. Like “SaaS

  • Tasos K.
    c# regex pattern-matching
    I have a string of the type2014-02-19 16:21:46,139 ERROR queue.TaskQueueEngine – failed toresolve task queue entry for first-level failure detection taskjava.sql.SQLException: Network error IOException: Connection timedout: connect 2014-02-19 16:35:48,247 ERROR [pool-1-thread-1]cluster.ClusterServiceImpl – unexpected error when trying to updateLastCheckinTime java.sql.SQLException: Network error IOException:Connection timed out: connect….I am trying to split it into substrings by date time

  • Cristian Velandia
    regex perl bash shell variables
    I need to execute my evaluateParameters.pl Perl program, for do it, i want to create a shell script.#!/bin/bashCOVARIANCE=~/Desktop/ncRNA/CovarianceModels/rRNAs_cov/bitscores.rRNA.dat # First input FILE BASEPATH=’/Desktop/ncRNA/Data/Inputs/rRNAs/60/’TRUEFILES=~/$BASEPATH/Infernal/*.table # Second input File CONTROLFILES=~/$BASEPATH/RandomControl/Infernal/*.table # third input file INPUTFILES=~/$BASEPATH/*.fasta # fourth input file for i in

  • brian d foy
    regex perl
    Is there a built-in way to escape a string that will be used within/as a regular expression? E.g.www.abc.comThe escaped version would be:www\.abc\.comI was going to use:$string =~ s/[.*+?|()\[\]{}\\]/\\$&/g; # Escapes special regex charsBut I just wanted to make sure that there’s not a cleaner built-in operation that I’m missing?

  • David Dury
    c# regex
    I need to match with regular expression the tokens from text:Hello {FullName}, I wanted to inform that your product {ProductName} is ready. Please come to our address {Address} to get it!How can I match the specific tokens in my text and fill the values using regex?Also I need to do it in a safe way and avoid every possible issues where the tokens my by misspelled or have something wrong, like bellow:**Hello {Full{Name}, I { wanted to inform that your product {{ProductName} is ready. Please come

  • Alan Moore
    php regex preg-replace
    I want to parse a file and I want to use php and regex to strip:blank or empty lines single line comments multi line commentsbasically I want to remove any line containing /* text */or multi line comments/*** some text *****/If possible, another regex to check if the line is empty (Remove blank lines)Is that possible? can somebody post to me a regex that does just that?Thanks a lot.

  • pythonian29033
    jquery regex jquery-validate
    I’ve been poring over this for hours, and at my wits’ end. I have two forms on the same page, both of which using jQuery validation to confirm valid data prior to submission.EDIT:Including the code below.Two things:For some reason, the first form (registration form) is being validated, AS I am entering data. So it appears it’s firing on keyup/blur events, but is NOT firing properly when I click the submit button. As you can plainly see, it allows the form to be submitted with empty OR invalid da

  • Tuan Dang
    regex notepad++
    I have a list of domains and subdomains stored in a .txt file (I’m using Windows XP).The format of the domains is this:somesite1.comsub1.somesite1.comsub2.somesite1.comsomesite2.comsub1.somesite2.comsub2.somesite2.comsomesite3.comsub1.somesite3.comsub2.somesite3.comI use notepad++, and I need to use regular expressions Anyway, I don’t know what to put in the find & replace boxes so it can go through the contents of the file and leave me with only the root domains. If done properly, it would

  • Omid
    php regex preg-match-all
    I want to extract the first paragraph of an article using RegEx and PHP. I started to write a RegEx as below:’/<p([^>]+)>(.*)<\/p>/i’That’s doing the job but the only little bug is that while markup is minified and in a one line as below:<p>First Paragraph</p><p>SecondParagraph</p>It simply matches all <p>First Paragraph</p><p>SecondParagraph</p>. Also, I know that a paragraph could not be inside another one but I have no control on

  • MengQi Han
    javascript regex string-parsing
    i am new to regex. I am trying to parse all contents inside curly brackets in a string. I looked up this post as a reference and did exactly as one of the answers suggest, however the result is unexpected.Here is what i didvar abc = “test/abcd{string1}test{string2}test” //any string var regex = /{(.+?)}/ regex.exec(abc) // i got [“{string1}”, “string1”]//where i am expecting [“string1”, “string2”]i think i am missing something, what am i doing wrong?updatei was able to get it with /g for a globa

  • the Tin Man
    ruby string string-parsing
    I have a string, say ‘123’, and I want to convert it to 123.I know you can simply do some_string.to_i, but that converts ‘lolipops’ to 0, which is not the effect I have in mind. I want it to blow up in my face when I try to convert something invalid, with a nice and painful Exception. Otherwise, I can’t distinguish between a valid 0 and something that just isn’t a number at all.EDIT: I was looking for the standard way of doing it, without regex trickery.

  • Bart Kiers
    c# string parsing function string-parsing
    I need to know if there is any library out there that will allow me to, given a certain string representing a mathematical function, say, x^2+x+1, (don’t care about how the string format, any will work for me) generates a C# func that will represent said function.

  • Danny Varod
    c# parameters string-parsing
    I Have a string array with 5 values, i want the program to loop even though i don’t enter a value for the arrays. If I split the arrays without inserting anything (pressing ….. (5 times “.” to split the array) then it doesn’t crash it will just loop. But if i just hit enter, then the program crashes.Is there a way to fix the loop so that even though there is no kind of input, that it won’t crash? (It also crashes if you don’t complete all 5 values.)Net = Console.ReadLine();string[] oktet = new

  • Scott Biggs
    android string nullpointerexception long-integer string-parsing
    I’ve spent the past two hours debugging what seems extremely unlikely. I’ve stripped the method of a secondary Android Activity to exactly this:public void onClick(View v) {String str = “25”;long my_long = Long.getLong(str); } // onClick (v)And yeah, I get a crash with the good ol’ NullPointerException:09-11 02:02:50.444: ERROR/AndroidRuntime(1588): Uncaught handler: thread main exiting due to uncaught exception 09-11 02:02:50.464: ERROR/AndroidRuntime(1588): java.lang.NullPointerExceptionIt lo

  • Jake King
    c string-parsing sscanf
    I’m parsing a string (a char*) and I’m using sscanf to parse numbers from the string into doubles, like so:// char* expression; double value = 0; sscanf(expression, “%lf”, &value);This works great, but I would then like to continue parsing the string through conventional means. I need to know how many characters have been parsed by sscanf so that I may resume my manual parsing from the new offset.Obviously, the easiest way would be to somehow calculate the number of characters that sscanf pa

  • relower
    javascript jquery regex string-parsing
    I want to parse Dailymotion video url to get video id in javascript, like below:http://www.dailymotion.com/video/x44lvdvideo id: “x44lvd”i think i need regex string to get a video id for all dailymotion video url combinations.i found url parser regex for YouTube links, its working well like below:var regExp = /^.*((youtu.be\/)|(v\/)|(\/u\/\w\/)|(embed\/)|(watch\?))\??v?=?([^#\&\?]*).*/;var match = url.match(regExp);var videoID = “”;if (match && match[7].length == 11){videoID = match[

  • Ocelot20
    c# .net type-conversion string-parsing
    Obviously this isn’t something you would want to do unless you’re in a helpless situation, but does anyone have a good example of something like this (bonus points for thinking of a clearer method name):public static object ConvertToBestGuessPrimitive(string toConvert) {if(looksLikeAnInt){return as an int;}else if(looksLikeABoolean){return as a boolean;}else{return as a string;} }The only idea I had was to chain together a bunch of TryParse methods together in a sensible order and fall back to s

Web site is in building