0

背景:URLファイル名のカスタム正規表現のような構文を開発しています。これは次のように機能します。

  • ユーザーは、のようなパターンを記述し、"[a-z][0-9]{0,2}"それを入力として渡します
  • それはプログラムによって解析され、それが表す順列のセットに変換されます。つまり、、、
    'a'.. ..'a0''a00''z99'

これらのパターンは複雑さが異なります。基本的に、URLファイル名に表示される可能性のあるものはすべて対応する必要があります。言語はJavaまたはPHPのいずれかですが、任意の言語の例または抽象的/概念的なヘルプは大歓迎です。

私の質問は次のとおりです。

  1. 上記の「パーサー」の実装から始める場所

そしてそれほど重要ではありませんが、

  1. 解析された複雑なパターンをプログラムで文字列に変換する方法
4

1 に答える 1

0

There is a good answer for this here: SO: /generate-all-permutations-of-text-from-a-regex-pattern-in-c

The crux of the thing is this...define what you really need well and figure out a way to halt once you have what you need and narrow your search range as much as possible because you are flirting with a quickly exploding number of permutations. "anything that could appear in a URL filename must be accommodated." is not going to cut it. For example, if you limit yourself to English characters and numbers, for a string 6 characters long you are looking at over 2 billion combinations. For each additional character multiply by 36.
If you go with ISO 8859 you get over 274 trillion combinations and Unicode over 745 trillion-trillion combinations.

于 2009-12-19T03:46:24.890 に答える