I would expect this line of JavaScript:  "foo bar baz".match(/^(\s*\w+)+$/)   to return something like:  ["foo bar baz", "foo", " bar", " baz"]   but instead it returns only the last captured match:  ["fo...
In Perl I can repeat a character multiple times using the syntax:  $a = "a" x 10; // results in "aaaaaaaaaa"   Is there a simple way to accomplish this in Javascript? I can obviously use a function, but I was wondering if there was...
In Python, where [2] is a list, the following code gives this output:  [2] * 5 # Outputs: [2,2,2,2,2]   Does there exist an easy way to do this with an array in JavaScript?  I wrote the following function to do it, but is there something shorter or...
I was wondering if there is a way to check for repeated characters in a string without using double loop. Can this be done with recursion?  An example of the code using double loop (return true or false based on if there are repeated characters in a...
I try to match/get all repetitions in a string. This is what I've done so far:  var str = 'abcabc123123'; var REPEATED_CHARS_REGEX = /(.).*\1/gi;  console.log( str.match(REPEATED_CHARS_REGEX) ); // => ['abca', '1231']...
In JavaScript, how can I repeat an array which contains multiple elements, in a concise manner?  In Ruby, you could do  irb(main):001:0> ["a", "b", "c"] * 3 => ["a", "b", "c", "a", "b&...
I'd like to find the longest repeating string within a string, implemented in JavaScript and using a regular-expression based approach.  I have an PHP implementation that, when directly ported to JavaScript, doesn't work.  The PHP implementat...
I want take a section of a picture, for example the middle of a picure, and repeat only that section in the background of a div. Is this even remotely possible? I suppose I could do this in javascript, but that would be messy.   In theory the answer...
I'm new student in here,sorry for asking simple question and I'm trying to solve a problem to count a same letter.  Input:"aabbcde" cause a = 2, b= 2, c= 1 , d =1 , e = 1 Output:"2a2b1c1d1e" or a2b2c1d1e1   and here's my c...

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.