Very simple really That’s it.
Tag: regex
For some silly reason we have a string with the following information We can use the regular expressions module to find and group the relevant information…just like this. That should output The regex broken down This gives us the name This gives us the telephone number Finally, this will give us the id
So we have the following string Except that it does not paint a good picture of Brighton, and The Man doesn’t like it. There are two things that we can do. We can substitute all the negative words with the same item using a list, or we can swap the negative words with nicer ones […]
We start with the string and we want to end up with Non-greedy First thing we do is delete everything from `string’ to `changed’ using .\{-} to mean `everything between’ and we end up with Using sets We can divide the strings into sets by encapsulating them in \( \). We can also use \a\{6} […]
Reformatting dates – Python
This little script will reformat a series of dates in a file, from 22 April 1980 to a more compact 19800422 ([yyyymmdd]) ISO standard, using the re and time libraries. Start with a file containing a series of dates Then this is the python code Now the output file will read