In PowerShell I've been trying different ways of stripping out all characters from a WinForms textbox other than the pattern I need and I cannot come up with a better solution for what I'm after; I am learning regex and need some guidance. This feels basic to me but I feel like I'm missing something obvious. I'm using the textbox's TextChanged event to prevent illegal characters from being typed and I have (what feels like) a bloated solution.
Goal:
- User allowed to type a single leading dollar sign followed by up to 6 chars from
[A-V0-9]- If no
$is typed, the first legal character typed should produce a leading$followed by said legal character (typingAwill produce$Ain the textbox) - If an illegal character is typed first, no leading
$should be produced in the textbox
- If no
- Illegal characters won't show up in the textbox
- Pasted text is processed/stripped as efficiently as possible
- The last character deleted will also delete the remaining
$- If textbox shows
$Tand user backspaces theTleaving a single$, the remaining$will also be deleted
- If textbox shows
Pasting into the textbox examples:
$$-#AZY$B9=%would become$AB9Z))
