---
title: Handy Regexes
tags: My coding notes
---
# Handy Regexes
### hard wrapping text:
find: `(.{1,80})( +|$\n?)|(.{1,80})`
replace: `$1$3\n`
comments: 80 is the line length
### Multiline Regular Expressions in Microsoft Visual Studio Code
The following modifiers make VSCode match the entire text containing the keyword:
[\s\S\n]*keyword[\s\S\n]*
Explanation of the Regular Expression:
\s: matches any whitespace character (space, table, line breaks)
\S: matches any character that is not a whitespace character
\n: matches a line feed character (code 10)
find: `US[\s\S\n]*Core[\s\S\n]*Screening[\s\S\n]*Response[\s\S\n]*Observation[\s\S\n]*Profile`
replace: `US Core Observation Screening Assessment Profile`
### creating a Automatic Generation of Header ID)
get section header in markdown. convert to lower case and append to page with anchor tag #
e.g.,
go from this:
~~~markdown
### Introduction
### About This Guide
### How to read this Guide
~~~
to this
~~~yaml
Introduction: index.html#introduction
About This Guide: index.html#about-this-guide
How to read this Guide: index.html#how-to-read-this-guide
~~~
find: ### (.*)
replace: $1:[NAME OF PAGE.html]#\L$1
make ID kebab case using infinite-width lookahead
find: `(?<=# .*)\s`
replace: `-`
### Generate a Markdown changelog list from Jira
1. run a search on Jira to get all the trackers with a change required ( or all of them for a ballot cycle depending on when you start applying them)
1. Export the trackers as ";" separated file with the columns Status, Change Category, Summary, Key, Related URL
1. Using a bit of regex magic, make the list by adding links to the tracker and adding a "See Changes Here" link
create/prepend markdown to the changelog page in the build
"regex magic":
find: `"(.*?)";"(.*?)";"(.*?)";"(.*?)";"(.*?)";.*`
replace: `1. **$1:** $2 ($3) $4 [$5](https://jira.hl7.org/browse/$5) See Changes [Here]($6)`
### Update relative URLto absolute version in change log
"regex magic":
find: `\]\((?!http)(.*)\)`
replace: `](https://hl7.org/fhir/us/core/<lastversion>/$1)`
### Generate Block Vote list from Jira
1. run a search on Jira to get all the trackers with a change required ( or all of them for a ballot cycle depending on when you start applying them)
1. Export the trackers as ";" separated file with the columns "key", summary", "reporter", "resolution","Change Impact";"Change Category";"Related Issues";"Related Issues"
1. Using a bit of regex magic, create the list to upload to Zulip
"regex magic":
find: ``"(.*?)";"(.*?)";"(.*?)";"(.*?)";"(.*?)";"(.*?)";"(.*?)";"(.*?)";"(.*?)";.*``
replace:
~~~
1. $1: $2 ($3) **$4** \n - Change Impact: $5 ($6 ) \n - Related and Duplicate Trackers: $7, $8, $9
~~~
### find words with periods for dot notation:
find: (\b[A-Za-z_.]+\.+\b.*?)<space> <<<< ends with a space
replace: `$1`<space> <<<<<add a space
### Clean up Generated Profile Compare Files
See
/Users/ehaas/Documents/Python/Jupyter/MyNotebooks/Validator_Tools/IG-Profile_Comparer.ipynb
1. look for "null" and remove ( e.g. in /Users/ehaas/Documents/Python/Jupyter/MyNotebooks/utils/out/profile_compare/temp_out/sd-argo-goal-us-core-goal.html)
1. find ` null"` and replace with `"`
2. fix bad links for publisher using regex
1. find `<a href="\?\?.*?>(.*?)</a>`
2. replace `$1`