Regex Help to replace substring with another

Hi all,

Having trouble replacing part of a string using regex.

I have a string that contains:

PVCu Window Group 3 Two Style056 Width: 1780 mm
Height: 1030 mm
Beading Style: Ovolo

I need the string to end up looking like:

PVCu Window Group 3 Two Style056
Width: 1780 mm
Height: 1030 mm
Beading Style: Ovolo

I can use the expression below to just selected the Style056 Width: 1780 mm but I cannot workout how to replace the whitespace character with a line break instead.
\bStyle\d*\s+\bWidth.*

Any thoughts? Thanks :slight_smile:

System.Text.RegularExpressions.Regex.Replace(<Your String>,"(?=.*)\s+(?=Width)",Environment.NewLine)

Replace with your string variable. Should be good to go.

Regards,
Nithin

1 Like

Perfect, thank you!

I need to try and workout regex more… lol

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.