Replace text starting “@” with respetive variables in Object – Javascript

I made this code trying to reproduce what i want to do in my Node JS API. I have “message” Array and “valueList” Object and i need to replace all text with “@” than have …

Replace an item in an array that doesn’t match any item in another array with a specific value

I’m still VERY new to Javascript and I’m having trouble with looping through an array and replacing items. I hope this explanation is clear. I have an array that looks like this: [ ‘1:1’, ‘blah’, …

Replace a specific character from a string with HTML tags

Having a text input, if there is a specific character it must convert it to a tag. For example, the special character is *, the text between 2 special characters must appear in italic. For example: …

How to select multiple lines in Sublime Text (quickly)

I have a JS file that has over 100000 lines of code, I want to get rid of the first 25000, I’ve been trying hard but can’t figure out how do I select them all at once (holding left mouse button and scrolling down is not an option as it would take forever). I guess holding SHIFT and arrow DOWN is the way to go, but I have absolutely no idea how to select them all at once anyway. Maybe selecting 25000th line, pressing shift, left arrow and then HOME would help, but I’m working on OS X and have

Regex to select words with spaces for subsititution

I have string in JS which where I need to add ‘ to the values. Example: task: task one, client: Mr jhon will be converted to task:’task one’, client: ‘Mr Jhon’ Think of these string as user entered search query. This is then sent to the backed for the searching. The values need to be enclosed in ‘ Complexities taskname: one two three, client: Mr Jhon there can be more than 2 words taskname: one two, client: Mr Jhon more than 1 space taskname:one,client: Mr Jhon can be singe word without space priority:1,groupname: Mr Singh the name of can be

remove last directory in URL

I am trying to remove the last directory part of an URL. My URL looks like this: https://my_ip_address:port/site.php?path=/path/to/my/folder. When clicking on a button, I want to change this to …

How to trim a file extension from a String in JavaScript?

For example, assuming that x = filename.jpg, I want to get filename, where filename could be any file name (Let’s assume the file name only contains [a-zA-Z0-9-_] to simplify.). I saw x.substring(0, x.indexOf(‘.jpg’)) on DZone Snippets, but wouldn’t x.substring(0, x.length-4) perform better? Because, length is a property and doesn’t do character checking whereas indexOf() is a function and does character checking. Answer If you know the length of the extension, you can use x.slice(0, -4) (where 4 is the three characters of the extension and the dot). If you don’t know the length @John Hartsock regex would be the right