I am running a project to extract specific text from a long string, it is working fine but I am facing a problem with few instances which contains brackets “( )” and there is no space between the previous word(s) and the openning bracket. For example,
Driver(Heavy Vehicle)
Team Leader(IT)
I need to insert a space before the openning bracket, to result the following:
Driver (Heavy Vehicle)
Team Leader (IT)
Not sure of Regex can help, or Concatinate function, need your help please.
Hi Anwar
you can try this approach
Text = “Driver(Heavy Vehicle) Team Leader(IT)”
Regex= System.Text.RegularExpressions.Regex.Replace(Text, “(\S)(”, “$1 (”)
Thanks Anil, I tried it but this will also add a space for those instances which already have a space, I am gonna have double space. Is there a way to check if a space is already available befoe implementing the replace function?
Thank you for your time, your solution is similar to Anil above, plz see my response to him. This solution will add unnecessary space to the cases where there is a space already. Can we check if there is a space availabe first befre taking the action?