For some unfathomable reason some journals (e.g. Lancet journals) require you to use floating decimal places instead of normal ones. This is a real pain to do, because you can’t just do a find and replace because that would also replace the full stops.
This is an opportunity to use a regex! ChatGPT tells us that “Regular expressions, commonly referred to as regex, are a powerful tool for searching, matching, and manipulating text. They are essentially a pattern-matching language used to identify specific sequences within strings of characters.” (see the bottom of the post for a ChatGPTxplanation of regex for biologists).
Google docs supports regex in the Find and Replace, as long as you tick the “User regular expressions” box:
Then, you put the below in the find and replace boxes:
Find – (?<=\d)\.(?=\d)
Press replace all and you’ll be done.
The explanation of the regex (from ChatGPT) is:
“This regular expression uses the following:
(?<=\d)– a positive lookbehind assertion that matches a digit (
\d) before the decimal point
\.– the decimal point to be replaced
(?=\d)– a positive lookahead assertion that matches a digit after the decimal point”
Full ChatGPT explanation of regex for biologists:
“Regular expressions, commonly referred to as regex, are a powerful tool for searching, matching, and manipulating text. They are essentially a pattern-matching language used to identify specific sequences within strings of characters. In the context of biology, regex can be used to analyze and process large datasets, such as DNA, RNA, or protein sequences.
Here’s a brief introduction to regex, tailored specifically for biologists:
- Basic elements: Regex uses a combination of literal characters and special symbols to define search patterns. For instance, the pattern “ATG” would match any occurrence of the letters “ATG” in a given sequence.
- Wildcards: The dot (.) character in regex is a wildcard, which matches any single character. For example, the pattern “A.G” would match any three-character sequence with “A” in the first position, “G” in the last position, and any character in the middle.
- Character classes: Square brackets () are used to define a set of characters that can match a specific position. For instance, the pattern “A[TG]G” would match “ATG” or “AGG” in a sequence.
- Quantifiers: These are used to specify the number of times a particular element should be repeated. Some common quantifiers include:
- (asterisk): matches zero or more repetitions of the preceding element (e.g., “A*G” would match “G,” “AG,” “AAG,” etc.).
- Anchors: These are used to define the position of a match within a string. The most common anchors are:
- ^ (caret): matches the start of a string (e.g., “^ATG” would match “ATG” only if it is at the beginning of a sequence).
- $ (dollar sign): matches the end of a string (e.g., “TAG$” would match “TAG” only if it is at the end of a sequence).
- Groups and alternation: Parentheses (()) are used to group elements in regex patterns, while the pipe symbol (|) denotes alternation (similar to “OR” in programming). For instance, the pattern “(ATG|TAG)” would match either “ATG” or “TAG” in a sequence.
By learning regex, biologists can efficiently process and analyze large datasets, search for specific genetic sequences, or identify motifs in proteins. This can be helpful in various biological research areas, such as genetics, genomics, and bioinformatics.”