Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
このテキスト「/text1/ text2 / text3 / endtag」があり、エンドタグの前の最後のテキスト(text3)を抽出したい場合、使用する必要がある正規表現パターンは何ですか?
私はこれを試しました:
/\/(.*)\// &
それは私にendtagの前にすべてを与えました。
以下は私に「text1」だけを与えました
/\/(.*?)\//
私は正規表現に関しては初心者ですので、あなたの助けと忍耐に前もって感謝します。
var matches = /([^\/]*)\/endtag$/.exec("/text1/text2/text3/endtag"); console.log(matches[1]);
「/」の後に「/endtag」と行末が続く文字列を一致させたいとします。