質問

なんだろうけど、日本人のアルゴリズム(または外部ライブラリするものなのかどうかに関しても変換する任意の文字列(以外を制御するCLSに対応してますか?

私の生成の動的RDLC(クライアントの報告書に定義)ASP.Net 報告書ビューア制御のフィールド名のフィールドの必要に基づく文字列を入力したユーザーです。

残念ながら私は少し制御の入力フィールドの名前、クライアントによる第3者CMS).私は、こうした非常に柔軟周辺の置換が必要に準拠した文字列になります。

い反応性のハッキングアルゴリズムの現在のもの

public static string FormatForDynamicRdlc(this string s)
{
    //We need to change this string to be CLS compliant.
    return s.Replace(Environment.NewLine, string.Empty)
        .Replace("\t", string.Empty)
        .Replace(",", string.Empty)
        .Replace("-", "_")
        .Replace(" ", "_");
}

は思います。そのアイデア?

注意:の場合のお役に立てるように、アルゴリズムを使用していを動的RDLCのBuildRDLC方法はこちら: http://csharpshooter.blogspot.com/2007/08/revised-dynamic-rdlc-generation.html

役に立ちましたか?

解決

このアルゴリズムを使っていをC/C++の識別子から任意の文字列(翻訳C#):

    static void Main(string[] args)
    {
        string input = "9\ttotally no @ # way!!!!";
        string safe = string.Concat("_", Regex.Replace(input, "[^a-z0-9_]+", "_"));
        Console.WriteLine(safe);
    }

のアンダースコアが不要な場合、最初の文字の正規表現、結果は数値配列となる。

他のヒント

こちらは正規表現した作することが分裂中核的労働基準に準拠した文字列の部分および非中核的労働基準に準拠した文字列です。以下の実装クライアントまで、フルのC#:

string strRegex = @"^(?<nonCLSCompliantPart>[^A-Za-z]*)(?<CLSCompliantPart>.*)";
Regex myRegex = new Regex(strRegex, RegexOptions.IgnoreCase | RegexOptions.CultureInvariant);
string strTargetString = @"                            _aaaaaa[5]RoundingHeader";

foreach (Match myMatch in myRegex.Matches(strTargetString))
{
  if (myMatch.Success)
  {
    // Add your code here
  }
}
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top