Replace a string containing spaces with an underscore using Microsoft Flow Power Automate Cloud. Create a new instant flow and initialize your string variable.
Add a Compose step with following expression to replace the string having spaces with an underscore. The below expression searches your string variable for spaces and replaces them with an underscore.
Run the flow and test this scenario.