Tagged Questions
0
votes
0answers
32 views
JavaScript regular expression literal as string literal
Please refer to this question for more discussion.
JavaScript string literal sometimes to many escaping slashes. The following address this problem by converting a regular expression literal into a ...
1
vote
1answer
151 views
Faster JavaScript fuzzy string matching function?
I'm using the following function to fuzzy match strings:
function fuzzy_match(str,pattern){
pattern = pattern.split("").reduce(function(a,b){ return a+".*"+b; });
return (new ...
0
votes
2answers
114 views
Elegant function to “increase” a JavaScript string - for example, turning “aac” into “aad”
I'm writing a function to increase a string so, for example, "aac" becomes "aad" and "aaz" becomes "aba". The result is horribly inelegant, I can't get it simple enough and I feel I'm missing ...
2
votes
1answer
64 views
Implement numbering scheme like A,B,C… AA,AB,… AAA…, similar to converting a number to radix26
I want to implement numbering scheme like Microsoft Word uses for numbering.
first one gets = A,next is B, next is C, .... then AA, then AB,....and so on.
as shown below
A
B
C
.
.
AA
...
3
votes
2answers
696 views
CoffeeScript date formatting
forceTwoDigits = (val) ->
if val < 10
return "0#{val}"
return val
formatDate = (date) ->
year = date.getFullYear()
month = forceTwoDigits(date.getMonth()+1)
day = ...
0
votes
2answers
42 views
Javascript Repeating Method… Better way to do this?
I'm sure there's a better way to approach the following. I'm writing a plugin. Users can enter settings in the following foramt: setting: "object1setting -> object2setting", It's done this way to ...
2
votes
1answer
202 views
How can I improve performance for my JavaScript table class?
I've written a JavaScript table class to make it easy to display tabular data and allow the user to sort the data by clicking on the table headers.
However, when there are hundreds of rows, ...
5
votes
2answers
204 views
String manipulations: transform “a-b-c” into “a(b(c))”
function dashesToParentheses(str) {
var list = str.split('-');
return str.replace(/-/g, '(') + repeatString(')', list.length - 1);
}
function repeatString(str, times) {
if (times == 1)
...
2
votes
3answers
590 views
String.IsNullOrWhiteSpace in JavaScript
I am aware of it being frowned upon to do something like write C# in JavaScript. (See Write Cobol in any language if you don't know what I'm talking about.)
But as a judgement call I think we could ...
3
votes
3answers
195 views
Improving the code to turn a string into an array of numbers?
I have a string of numbers, like "31654918562314", and I want to convert it into an array of integers. The code I've written is:
string source = "31654918562314";
int[] numbers = new ...
0
votes
1answer
128 views
Making an encoding function faster
I currently have this encoding function which simply subtracts one from each character code:
String.fromCharCode.apply(null, text.split("").map(function(v) {
return v.charCodeAt() - 1;
}));
...
6
votes
2answers
6k views
Pack and unpack bytes to strings
I need to write a function that "packs" an array of bytes (integers between 0 and 255) into a string. I also need to be able to perform the reverse operation, to get my byte array from the string that ...