// 3. here document string converted to a regex regex = '''(?ix)(\\d+)\\s+\\d+%\\s+(/nfs/data.*)''' pattern = ~regex
Essentially, when converting a slashy regex to a string based pattern:
- Forward slashes don't need to be escaped by back slashes so "\/" becomes "/"
- Double the remaining back slashes. Back slashes need to be escaped by back slashes when quoting strings (either normal or here documents)
- If you want to match whitespace, then you must use
- You can match "#" with
so that it's not interpreted as the beginning of a comment