REgular expressions drive me nuts. Mostly because I learned text search and replace in MS Word.
Find everything after the last / including the / itself
for LibreWriter advanced search and replace
[^/]+$
For other
echo string/string/string | /[^/]*$
everything up to the last occurrence of /
echo string | sed 's/\(.*\)/.*//'
A great site that has active testing — incredible
Here is a cheat sheet:
http://www.rexegg.com/regex-quickstart.html
Here is a document:
https://www.princeton.edu/~mlovett/reference/Regular-Expressions.pdf
Here are a few examples that work for me:
Find
‘.*$
Starting with a single quote (‘) or whatever you need to match, match any character (.) zero or more times (*) until the end of the line ($).
(?<=’).*$
This basically says give me all characters that follow the ‘ char until the end of the line.
‘.*?\n
This would only capture everything from ‘ until end of that line
Find and replace keeping what was found:
Find: any phrase with an two numbers followed by a forward slash and followed by any two numbers:
\([0-9][0-9]/[0-9][0-9] +\)
Replace:
\1\t
Find: anything like 10/21 and put it into a variable
The \( and +|) make what’s between become a variable that can be used. If there were more than one set of those separated by a dot then there would be more variables.
Replace: the \1 represents the variable while the \t represents a tab. The result is that a tab has been inserted after the find expression.
If more than one variable was used, i.e. \(dutch+\) \(bros+\) then the variables are \1 and \2.
To replace “dutch bros” with “dutch and bros”, search for
\(dutch+\) \(bros+\)
and replace with
\1 and \2