正規表現を学ぼうとしています。私は基本を知っています、そして私は正規表現でひどいわけではありません、私はただプロではありません-それで私はあなたたちに質問があります。正規表現を知っているなら、きっと簡単でしょう。
私が現在持っているのはこれです:
/(\w+)\s-{1}\s(\w+)\.{1}(\w{3,4})/
私がやろうとしているのは、すべてのファイル名をフォーマットすることによって私の音楽コレクションを整理する小さなスクリプトを自分で作成することです。すでに他のものがあることは知っていますが、これは私にとって学習体験です。「地獄は楽しい所」のようなものを「地獄は楽しい所」に置き換えて、すでにすべてのタイトルを台無しにしました。私の知恵では、どういうわけか「Hell Aint a ad Place to be」(Aの後にスペースと大文字が続く)になってしまいました。明らかに、それは修正するのが悪夢であり、手動で行う必要がありました。言うまでもなく、私は今最初にサンプルをテストしています。
とにかく、上記の正規表現は、多くのステージ1のようなものです。最終的にはそれを構築したいのですが、今のところは単純なビットを機能させる必要があります。
最後に、私は向きを変えたいと思います:
"arctic Monkeys- a fake tales of a san francisco"
の中へ
"Arctic Monkeys - A Fake Tales of a San Francisco"
「-」の後にある場合は、後ろ向きのアサーションが必要になることはわかっています。最初の単語が「a」、「of」などで、通常は小文字である場合は、大文字にする必要があるためです(上記私が知っているこのユースケースの悪い例です)。
既存の正規表現を修正する方法はどれも素晴らしいでしょうし、残りを仕上げるために虎の巻をどこで見るかについてのヒントは素晴らしいでしょう(私はすることを学ぶ必要があるので、本格的な答えを探していませんそれ自体、なぜw +が1つの単語しか取得していないのか理解できません)。