Am working on a decipher algorithm that is supposed to take a string input of en english sentence flipped backwards and contains numbers, spaces and delimiters.
I got code that removes numbers and special characters but also removes spaces, Can you help me tell this code to not bully the spaces and just leave them in my string, Thank You.

using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;

public class Program
{
    static List<string> mywords=new List<string>();
    public static void Main()
    {
        string inp=Console.ReadLine();
        string answer=Regex.Replace(inp,"[^a-zA-Z]", "");
        string replacement=reverse(answer);
        Console.WriteLine(replacement);
    }
    private static string reverse(string b){
     string reverse="";int Length=0;
          Length = b.Length - 1;  
            while(Length>=0)  
            {  
                reverse = reverse + b[Length];  
                Length--;  
            }  
        return reverse;
    }
}

Questions:

  1. Are the spaces gone after line 11?
    If so, examine your regex parameters.
  2. Why is "" in line 11? I checked some documentation it seems like we don't need that.
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.