Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

SOLVED: Search Simultaneous Special Characters in a string using PowerShell

NottyHead:

I am trying to work on an issue where if a String has multiple "special characters " in a string how do I replace that with a single Character. For Example: -


$a = "INC0010347~INC0010348~~INC0010349"
$a = $a.Replace("~~","~")
$a

Result 1: - "INC0010347~INC0010348~INC0010349"

In the above case a Replace function would work if the characters are 2 in number. However anything more than 2 will fail.. as in the below:


$a = "INC0010347~INC0010348~~~INC0010349"
$a = $a.Replace("~~","~")
$a

Result 2: - "INC0010347~INC0010348~~INC0010349"

I am working on a script that would help me do this dynamically irrespective of the number of special characters (in this case tilde(~)) the result should be

Result 1: - "INC0010347~INC0010348~INC0010349"



Posted in S.E.F
via StackOverflow & StackExchange Atomic Web Robots
This Question have been answered
HERE


This post first appeared on Stack Solved, please read the originial post: here

Share the post

SOLVED: Search Simultaneous Special Characters in a string using PowerShell

×

Subscribe to Stack Solved

Get updates delivered right to your inbox!

Thank you for your subscription

×