Skip to content
Advertisement

Tag: replace

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

Replace spaces with dashes and make all letters lower-case

I need to reformat a string using jQuery or vanilla JavaScript Let’s say we have “Sonic Free Games”. I want to convert it to “sonic-free-games”. So whitespaces should be replaced by dashes and all letters converted to small letters. Any help on this please? Answer Just use the String replace and toLowerCase methods, for example: Notice the g flag on

How to program a text search and replace in PDF files

How would I be able to programmatically search and replace some text in a large number of PDF files? I would like to remove a URL that has been added to a set of files. I have been able to remove the link using javascript under Batch Processing in Adobe Pro, but the link text remains. I have seen recommendations

Advertisement