Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Basically you want to look for all sequences of digits optionally ending with a decimal point and another digit sequence and then append a 'c'. Here's an example, assuming you're using Perl (your question doesn't say):</p> <pre><code>$_ = 'treand60(12.3)/1010 + 1 &gt;1010'; s/\b\d+(?:\.\d+)?/$&amp;c/g; print; # output is "treand60(12.3c)/1010c + 1c &gt;1010c" </code></pre> <p><code>\d+</code> is 1 or more digit and then <code>\.\d+</code> is 1 or more digit after a decimal point. The <code>(?: ... )</code> is a <a href="http://perl.active-venture.com/pod/perlretut-noncapturing.html" rel="nofollow noreferrer">non-capturing group</a>. The last <code>?</code> means "match zero or one of these" (i.e. it's optional). And the <code>\b</code> means match only on word boundaries (this prevents something like "Hello123" from matching because the number comes directly after a word character).</p> <p>Here is the C# equivalent:</p> <pre><code>using System.Text.RegularExpressions; // ... string input = "treand60(12.3)/1010 + 1 &gt;1010"; Regex regex = new Regex(@"\b\d+(?:\.\d+)?"); string output = regex.Replace(input, (m) =&gt; m.Value + 'c'); Console.WriteLine(output); // prints "treand60(12.3c)/1010c + 1c &gt;1010c" </code></pre> <p>The lambda expression inside the <a href="http://msdn.microsoft.com/en-us/library/system.text.regularexpressions.regex.replace.aspx" rel="nofollow noreferrer">Regex.Replace</a> call is a <a href="http://msdn.microsoft.com/en-us/library/system.text.regularexpressions.matchevaluator.aspx" rel="nofollow noreferrer">MatchEvaluator</a> which simply gets the match text and appends a 'c'.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload