The removed "legacy" appearance promoted input placeholders to the floating label if the label was not specified. All newer appearance settings require explicitly specifying a if one was not provided before. This change addresses an accessibility best practice of not using labels and placeholders interchangeably.
Migrating to MDC-based Angular Material Components | Form Fields
This regular expression works with IntelliJ IDE and maybe with others, supporting regex search and replace.
(?s)(\s+)(<[a-z-]+[^>]*?)\s+placeholder=\"([^"]*)\"
$1<mat-label>$3</mat-label>$1$2
(?s)
- makes the dot match all characters, including line breaks(\s+)
- group to fetch whitespace to correctly indent code(<mat-[^>]*?)
- non greedy search group until ...\s+placeholder=
...we find the placeholder and possbile whitespace to replace the wholeplaceholder
attribute([^"]*)
- the actual content of our our new<mat-label>
Thanks for this. I had a an error when using in VSCode and ended up using CoPilot to modify it to this:
Find
Replace