I have a value I am pulling into a string that looks like this:
M'arta
I need to have it to translate the numeric value into an actual value so that the string looks like this:
M’arta
Any ideas on how to accomplish this in VB.NET? Here is the relevant line of code that returns this result:
Dim occupant as String = GridView1.Rows(e.RowIndex).Cells(2).Text
Below is the VB (& C#) version to what you’re asking. Basically, use the MatchEvaluator argument in the Regex method to allow custom parsing of the matches. In this case, we find any instances of
#<1-3_digit_number>we want to strip the `# symbol, and convert the decimal code.I added a second conversion in your string (
#116) just for testing purposes. You could refactor this in to a custom method and (not sure if VB has it) lambda expression to make it universal, but I’ll leave that up to you.VB.NET Version (DEMO)
C# Version (DEMO)
For archival purposes, here are the versions that support
&#___;below:VB.NET (DEMO)
C# (DEMO)