-1

次のテキストの正規表現を取得する方法を知りたいです。

XXXXXX[Some Same Text # AAAA-NNNN]XXXXXX

どこ:

'X' can vary any text: Alfa, numerical or symbols (The X can have 0 to infinite characters and it is NOT obligatory).
'A' Alfa uppercase text (The Alfa has exactly 4 uppercase letters and it is obligatory).
'N' Numbers (The N have exactly 4 numbers and it is obligatory).
'Some Same text' has exactly the same text always and it is obligatory.
'[,],#,-' will always be there in that same possition and it is obligatory.

次の preg_match があります。

*[Some Same Text([A-Z]{4})-([0-9]{4})]*

そして、それは機能していないようです。

よろしくお願いします!

4

2 に答える 2

2

.任意の文字に一致し、*0..無限を意味します。使用するときは、それらをエスケープする必要があります[]これを試して:

.*\[Some Same Text # ([A-Z]{4})-([0-9]{4})\].*
于 2013-06-14T22:32:27.620 に答える