I have a specific issue hopefully someone can help with. I currently have the string “Full Time : Regular” and I want to replace/enter a hyphen where the space between full and time is. I’m not sure of the best practice.
I don’t want to do a simple replace on the space because I want to keep the other spaces. I was thinking of trimming the first 4-5 characters (Full) and then concatenating a hyphen on the end? But I’m not sure how to go about this.
@ClaytonM always has the best answers but you can replace more than just single characters with string.replace. For simplicity, if it’s always “Full Time”, you could just do a string.replace(“Full Time”, “Full-Time”). If you have “Full Time” and “Part Time” in string variables, just string.replace(" Time", “-Time”)
That solution works but it adds an extra space that is not wanted. It looks like “Full -Time : Regular” but in order to be entered into the software the space after “Full” must not be there
Did you try both solutions?, and if there’s a dynamic chance that there are multiple spaces, then Regex might work better. Also check for typos if you included an extra space somewhere.
I only tried the replacing Time with -Time solution because I had found another one on my own. I ended up converting to an array of characters, removing the space character, and inserting a hyphen in its spot.