Hot answers tagged

8

Since you have basically the same statements over and over with different parameters, this can be turned into a loop. You can pair the pattern and the string you want to use to replace in a dict. This makes it clear what is paired with what. Take a look: import re def strip_html(raw_html: str) -> str: pairs = { '<.*?>': ' ', '&...


4

The problem with this approach is that it won't scale well and if you want to extract text from diverse sources it will be impossible to handle all possible cases. Regular expressions can be expensive, and if you have lots of text to process I would worry about performance. For many operations like changing '&amp;' to '&', a regex is not even ...


2

In addition to the other good suggestions, don't pipe sed to another invocation of sed, use a semi-colon to separate multiple commands. Also you might want to make your toCamelCase method more generic, e.g. echo "Something_with-a bit_of Variety" | sed -E 's/[ _-]([a-z])/\U\1/gi;s/^([A-Z])/\l\1/' outputs somethingWithABitOfVariety or even echo "...


1

Initial thoughts Looking at the MDN documentation for Element.animate() I see this warning at the top: This is an experimental technology Check the Browser compatibility table carefully before using this in production. Looking at that compatibility table we see it isn't supported at all by a couple browsers... I searched for "navigator.sayswho" ...


Only top voted, non community-wiki answers of a minimum length are eligible