What is the best way to remove all text in a string after a specific character? In my case "=" and after another character in my case a
,, but keep the text between?
Another way to do this is with operator -replace.
$teststring = "test=keep this, but not this." $teststring -replace ".*=" -replace ",.*"
.*= means any number of characters up to and including an equals sign.
,.* means a comma followed by any number of characters.
Since you are basically deleting those two parts of the string, you don't have to specify an empty string with which to replace them. You can use multiple -replaces, but just remember that the order is left-to-right.
- Splitting this string to get the max count to a corresponding character
- How do I add Thousands separator to my html form
- Applying ACL Permissions using PowerShell Set-Acl
- Function when returning a paragraph python [closed]
- Replace multiple strings in one gsub() or chartr() statement in R?
- how to read value from string.xml in android?
- Count digits as separate words using str_word_count in PHP
- Get matches from a preg_replace and use them as an array key
- How use ' '.join() in Python?
- How to fix failed VMSS deployment with error “unknown network allocation error”