add a space between characters RRS feed

  • Question

  • Hi i would like to do the following 

    i have a variable and would like to get the following.

    Team one = Do nothing 
    Teamone = change to "Team one"


    Friday, October 12, 2018 11:49 AM

All replies

  • What's your variable? and is that text: team one in the variable?

    if ($x -eq "Teamone"){$x = "Team one"}

    Or, since your variable always needs to be the same text it seems.... just do:

    $x = "Team one"

    Friday, October 12, 2018 12:04 PM
  • Hi, 

    the variable is a team name but not static. 

    So it can be Team one but also team ten, its a variable that people can fill in by a text field. 

    i ask them to fill in the team name, but they can fill it in with or without Team in front 

    my script works only with the name of the team. 

    When they fill in "ONE" my script works.

    So "Team ONE" should become ONE 

    $first,$last = ($teaminput.tolower()).Split(" ")
    IF([string]::IsNullOrEmpty($last)) {            
        $team = $first  
    } else {  
        $team = $last       

    This also works but when the fill in TeamOne i can not split and make it ONE.

    (this also needs to work when its Team Two or Three or Four.)

    Friday, October 12, 2018 1:26 PM
  • This seems to work for me:

    $Value = "TeamEleven"
    If ($Value -Like "$Team *") {# Do nothing.}
    Else {$Value = $Value.Replace("Team", "Team ")}

    Richard Mueller - MVP Enterprise Mobility (Identity and Access)

    Friday, October 12, 2018 1:38 PM