using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"\$([\w]+)->([^\W]+)";
string substitution = @"$\1['\2']";
string input = @" @foreach($fsn_uploaded_data as $client_no => $client)
<div class=""client"" style=""border: 1px solid #888; margin-bottom: 10px;"">
<h2>{{ $client['client_name'] or '-' }}</h2>
<p>{{ $client->postal_address or '-' }}, {{ $client->zip_code_postcode or '-' }}, {{ $client->city or '-' }}, {{ $client->countr_code or '-' }}</p>
}
{{-- @foreach($client->delivery_addresses as $delivery_no => $address)
<div class=""delivery_addresses"" style=""border: 1px solid #ddd; margin: 5px;"">
<h3>{{ $address->client_delivery_name or '-' }}</h3>
<p>{{ $address->delivery_address or '-' }}, {{ $address->zip_code or '-' }}</p>
</div>
@endforeach --}}
</div>
@endforeach";
Regex regex = new Regex(pattern);
string result = regex.Replace(input, substitution);
}
}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for C#, please visit: https://msdn.microsoft.com/en-us/library/system.text.regularexpressions.regex(v=vs.110).aspx