Note that there are some explanatory texts on larger screens.

plurals
  1. POReplace text while keeping case intact in C#
    primarykey
    data
    text
    <p>I have a set of sentences i need to use to do a replace, for example:</p> <pre><code>abc =&gt; cde ab df =&gt; de ... </code></pre> <p>And i have a text where to make the changes. However i have no way to know beforehand case of said text. So, for example, if i have:</p> <pre><code>A bgt abc hyi. Abc Ab df h </code></pre> <p>I must replace and get:</p> <pre><code>A bgt cde nyi. Cde De h </code></pre> <p>Or as close to that as possible, i.e. keep case</p> <p><strong>EDIT:</strong> As i am seeing to much confusion about this i will try to clarify a bit:</p> <p>I am asking about a way to keep caps after replacing and i don't think that passed through well (not well explained what thaat entails) so i will give a more realistic example using real words.</p> <p>think of it like a gossary, replacing expressions by their sinonyms so to speak, so if i map:</p> <pre><code>didn't achieve success =&gt; failled miserably </code></pre> <p>then the i get as input the setence:</p> <pre><code>As he didn't achieve success, he was fired </code></pre> <p>i would get</p> <pre><code>As he failled miserably, he was fired </code></pre> <p>but if didn't was capitalized, so would failled, if achieve or success was capitalized, so would miserably, if any had more than 1 letter capitalized, so would it's counterpart</p> <p>My main possibilities are (ones i really want to take into cosideration)</p> <ul> <li>only first letter of first word capitalized</li> <li>only first letter of every word capitalized</li> <li>all letters capitalized</li> </ul> <p>If i can handle those three that would be acceaptable already i guess - it's the easyer ones - of course a more in depth solution would be better if availlable</p> <p>Any ideas?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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