{"id":104,"date":"2022-11-15T13:44:23","date_gmt":"2022-11-15T12:44:23","guid":{"rendered":"https:\/\/sys-code-alpha.com\/?p=104"},"modified":"2022-11-15T13:44:23","modified_gmt":"2022-11-15T12:44:23","slug":"smart-string-modification-filter","status":"publish","type":"post","link":"https:\/\/sys-code-alpha.com\/?p=104","title":{"rendered":"Smart string modification filter."},"content":{"rendered":"\n<p>This is a string modification filter that is intended to calculate the string char value and increment it.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>filter Set-StringIncrement{\r\n\r\n  &lt;#\r\n  PS> 10 | Set-StringIncrement\r\n  11\r\n  PS> 'aa' | Set-StringIncrement\r\n  ab\r\n  #>\r\n\r\n  BEGIN{\r\n      filter Set-CharIncrement{\r\n\r\n          &lt;#\r\n          PS> 'a' | Set-CharIncrement\r\n          b\r\n          PS> '1' | Set-CharIncrement\r\n          2\r\n          #>\r\n      \r\n          PROCESS{\r\n              IF($_ -is &#91;int]){ IF($_ -eq 9){ 'A' }ELSE{ $_ + 1} }\r\n              IF($_ -is &#91;string]){ IF($_ -eq 'Z'){ 0 }ELSE{ $char = &#91;int]&#91;char]$_ + 1; &#91;char]$char }}\r\n          }\r\n      }\r\n  }\r\n \r\n  PROCESS{\r\n      $Arr1 = $_.tostring()\r\n      $Arr1 = $Arr1.ToCharArray()\r\n      $Arr2 = $Arr1 | %{ &#91;char]$_} | %{ $_.ToString()  } | %{ $element = $_; TRY{&#91;int]$element}Catch{&#91;string]$element} }                       \r\n      &#91;array]::Reverse($Arr2)\r\n      $script:Out = $null        \r\n      $Arr2 = $Arr2 | %{                      \r\n                  $Element = $_\r\n                  IF($script:Out -eq $null){\r\n                              $script:Out = $Element | Set-CharIncrement                                \r\n                              $Script:Out\r\n                  }ELSEIF($script:Out -eq 0){ \r\n                              $script:Out = $Element | Set-CharIncrement                                \r\n                              $Script:Out \r\n                  }ELSEIF($script:Out -ne 0){ \r\n                              $Element \r\n                  }\r\n               }\r\n      &#91;array]::Reverse($Arr2)\r\n      $Arr2 -join ''\r\n  }\r\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>This is a string modification filter that is intended to calculate the string char value and increment it.<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/sys-code-alpha.com\/index.php?rest_route=\/wp\/v2\/posts\/104"}],"collection":[{"href":"https:\/\/sys-code-alpha.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sys-code-alpha.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sys-code-alpha.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/sys-code-alpha.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=104"}],"version-history":[{"count":1,"href":"https:\/\/sys-code-alpha.com\/index.php?rest_route=\/wp\/v2\/posts\/104\/revisions"}],"predecessor-version":[{"id":105,"href":"https:\/\/sys-code-alpha.com\/index.php?rest_route=\/wp\/v2\/posts\/104\/revisions\/105"}],"wp:attachment":[{"href":"https:\/\/sys-code-alpha.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=104"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sys-code-alpha.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=104"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sys-code-alpha.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=104"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}