Hi,
Try your regex outside of workflow and see if you observe the same behaviour. If yes, you need to fix that first. I don't think this has anything to do with workflow.
Also, to find/replace double spaces, you could have also used the simple replace function. Refer below sample-
=======
public void GetAccounsWithDoubleSpaces()
{
using (service = new OrganizationServiceProxy(new Uri(_organizationURI), null, _credential, null))
{
string fetchXml = @"<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false' >
<entity name = 'account' >
<attribute name='name'/>
<filter type='and'>
<condition attribute='name' operator='like' value='% %' />
</filter>
</entity>
</fetch>";
var allAccount = service.RetrieveMultiple(new FetchExpression(fetchXml));
foreach (var acc in allAccount.Entities)
{
// Current Name
var currentAccountName = acc["name"];
Console.WriteLine(currentAccountName);
// Replace double spaces
var updateAccountName = acc["name"].ToString().Replace(" ", "");
Console.WriteLine(updateAccountName);
// Replace double space in the entity object
var accountUPD = new Entity(acc.LogicalName, acc.Id);
accountUPD["name"] = updateAccountName;
service.Update(accountUPD);
}
}
}
==================
Hope this helps.